Package org.apache.lucene.document

Examples of org.apache.lucene.document.Field


    d1.add(buildMetaField("custom","000003"));
    d1.add(buildMetaField("latitude", "60"));
    d1.add(buildMetaField("longitude", "120"));
    d1.add(buildMetaField("salary", "04500"));
   
    Field sf = new Field("testStored","stored",Store.YES,Index.NOT_ANALYZED_NO_NORMS);
    sf.setOmitTermFreqAndPositions(true);
    d1.add(sf);
   
    Document d2=new Document();
    d2.add(buildMetaField("id","2"));
    d2.add(buildMetaField("shape","rectangle"));
View Full Code Here


  }

    private void addMetaDataField(Document doc, String name,String[] vals)
    {
      for (String val : vals){
        Field field = new Field(name, val,Store.NO,Index.NOT_ANALYZED_NO_NORMS);
        field.setOmitTermFreqAndPositions(true);
        doc.add(field);
      }
    }
View Full Code Here

          String propVal = data.get(propName);
          contentBuffer.append(propVal).append(" ");
          String[] valList = propVal.split(",");
          for (String val : valList)
          {
            Field f = new Field(propName,val,Store.NO,Index.NOT_ANALYZED_NO_NORMS);
            f.setOmitTermFreqAndPositions(true);
            doc.add(f);
          }
          doc.add(new Field(CONTENTS_FIELD_NAME,contentBuffer.toString(),Store.NO,Index.ANALYZED));
        }
        return doc;
      }
      else
      {
View Full Code Here

    else {
      sText = "";
    }

    Document oDoc = new Document();
    oDoc.add (new Field ("workarea" , sWorkArea, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("container", sContainer, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("guid"     , sGuid, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("number"   , dNumber.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("created"  , DateTools.dateToString(dtSent, DateTools.Resolution.SECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("size"     , Gadgets.leftPad(String.valueOf(iSize),'0',10), Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("title"    , Gadgets.ASCIIEncode(sSubject), Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field ("author"   , Gadgets.ASCIIEncode(sAuthor), Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field ("abstract" , sAbstract, Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field ("recipients",sRecipients, Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field ("comments" , sComments, Field.Store.NO, Field.Index.TOKENIZED));
    oDoc.add (new Field ("text"     , sText, Field.Store.NO, Field.Index.TOKENIZED));

    if (DebugFile.trace) DebugFile.writeln("IndexWriter.addDocument([Document])");

    oIWrt.addDocument(oDoc);
View Full Code Here

    throws ClassNotFoundException, IOException, IllegalArgumentException,
             NoSuchFieldException, IllegalAccessException, InstantiationException,
             NullPointerException {

    Document oDoc = new Document();
    oDoc.add (new Field ("workarea" , sWorkArea, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("container", sContainer, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("guid"     , sGuid, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("created"  , DateTools.dateToString(dtCreated, DateTools.Resolution.SECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field ("title"    , sTitle, Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field ("author"   , sAuthor, Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field ("text"     , sText, Field.Store.NO, Field.Index.TOKENIZED));
    if (sText.length()>80)
      oDoc.add (new Field("abstract", sText.substring(0,80), Field.Store.YES, Field.Index.TOKENIZED));
    else
      oDoc.add (new Field("abstract", sText, Field.Store.YES, Field.Index.TOKENIZED));
    oIWrt.addDocument(oDoc);
  } // addNewsMessage
View Full Code Here

    throws ClassNotFoundException, IOException, IllegalArgumentException,
             NoSuchFieldException, IllegalAccessException, InstantiationException,
             NullPointerException {

    Document oDoc = new Document();
    oDoc.add (new Field("workarea" , sWorkArea, Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field("container", sProject , Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field("guid"     , sGuid    , Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field("number"   , String.valueOf(iNumber), Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field("title"    , sTitle, Field.Store.YES, Field.Index.TOKENIZED));
    oDoc.add (new Field("created"  , DateTools.dateToString(dtCreated, DateTools.Resolution.SECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
    oDoc.add (new Field("writer"   , sWriter, Field.Store.YES, Field.Index.UN_TOKENIZED));
    if (null!=sStatus)     oDoc.add (new Field("status"   , sStatus, Field.Store.YES, Field.Index.UN_TOKENIZED));
    if (null!=sType)       oDoc.add (new Field("type"     , sType  , Field.Store.YES, Field.Index.UN_TOKENIZED));
    if (null!=oPriority)   oDoc.add (new Field("priority" , oPriority.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
    if (null!=oSeverity)   oDoc.add (new Field("severity" , oSeverity.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
    if (null!=sReportedBy) oDoc.add (new Field("author"   , sReportedBy, Field.Store.YES, Field.Index.TOKENIZED));
    if (null==sComments)
      oDoc.add (new Field("comments", "", Field.Store.NO, Field.Index.TOKENIZED));
    else
      oDoc.add (new Field("comments", sComments, Field.Store.NO, Field.Index.TOKENIZED));
    if (null==sText) {
      oDoc.add (new Field("text", "", Field.Store.NO, Field.Index.TOKENIZED));
      oDoc.add (new Field("abstract", "", Field.Store.YES, Field.Index.TOKENIZED));
    } else {
      oDoc.add (new Field("text", sText, Field.Store.NO, Field.Index.TOKENIZED));
      if (sText.length()>80)
        oDoc.add (new Field("abstract", sText.substring(0,80).replace('\n',' ').replace('\r',' '), Field.Store.YES, Field.Index.TOKENIZED));
      else
        oDoc.add (new Field("abstract", sText.replace('\n',' ').replace('\r',' '), Field.Store.YES, Field.Index.TOKENIZED));
    }
    oIWrt.addDocument(oDoc);
  } // addBug
View Full Code Here

      sFieldName = (String) oKeys.next();
      oFieldValue = oKeywords.get(sFieldName);
      if (null==oFieldValue) oFieldValue = "";
     
      if (oFieldValue.getClass().getName().equals("java.util.Date"))
        oDoc.add(new Field(sFieldName, DateTools.dateToString((Date) oFieldValue,  DateTools.Resolution.SECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
      else
        oDoc.add(new Field(sFieldName, (String) oFieldValue, Field.Store.YES, Field.Index.UN_TOKENIZED));
    } // wend

  // ******************************************************
  // Index titles, authors, etc. as stored tokenized fields

    Iterator oTxts = oTexts.keySet().iterator();
    while (oTxts.hasNext()) {
      sFieldName = (String) oTxts.next();
      oFieldValue = oTexts.get(sFieldName);
      if (null==oFieldValue) oFieldValue = "";
      oDoc.add(new Field(sFieldName, (String) oFieldValue, Field.Store.YES, Field.Index.TOKENIZED));
    } // wend

  // *********************************************
  // Index full texts as unstored tokenized fields
 
    Iterator oUnStor = oUnStored.keySet().iterator();
    while (oUnStor.hasNext()) {
      sFieldName = (String) oUnStor.next();
      oFieldValue = oUnStored.get(sFieldName);
      if (null==oFieldValue) oFieldValue = "";
      oDoc.add(new Field(sFieldName, (String) oFieldValue, Field.Store.NO, Field.Index.TOKENIZED));
    } // wend
    oIWrt.addDocument(oDoc);
  } // add
View Full Code Here

    writer.addDocument(doc);
  }
 
  private void addStoredField(Document doc, String fieldName, String value)
  {
    Field field = new Field(fieldName, value, Store.YES, Index.NO);
    doc.add(field);
  }
View Full Code Here

 
  private void addTextField(Document doc, String fieldName, String[] sections)
  {
    for(int i = 0; i < sections.length; i++)
    {
      Field field = new Field(fieldName, new SectionTokenStream(analyzer.tokenStream(fieldName, new StringReader(sections[i])), i));
      doc.add(field);
    }
  }
View Full Code Here

 
  private void addMetaDataField(Document doc, Term term, int[] meta)
  {
    IntMetaDataTokenStream tokenStream = new IntMetaDataTokenStream(term.text());
    tokenStream.setMetaData(meta);
    Field field = new Field(term.field(), tokenStream);
    doc.add(field);
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.document.Field

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.