Package org.apache.lucene.document

Examples of org.apache.lucene.document.Field$Store


    /**
     * ��������
     */
    protected static int addIndex() throws IOException {
    Document doc = new Document();
    doc.add(new Field("id", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
    doc.add(new Field("author", "����IBM OSIһһ����", Field.Store.YES, Field.Index.TOKENIZED));
    doc.add(new Field("time", Long.toString(System.currentTimeMillis()), Field.Store.YES, Field.Index.UN_TOKENIZED));
    doc.add(new Field("content", "��֪����ʲôʱ��ʼ����ʲô�������涼�и����ڣ��ﵶ�����ڣ����ͷ����ڣ�������ֽ������ڣ��ҿ�ʼ���ɣ�����������ϣ�����ʲô�����Dz�����ڵģ�", Field.Store.NO, Field.Index.TOKENIZED));
    IndexWriter writer = getWriter();
    try {
        writer.addDocument(doc);
        writer.optimize();
    }finally {
View Full Code Here


      Document doc = (Document)hits.doc(i);
      //ӳ���ĵ����Ե�Java������
      Object result = params.getSearchObject().newInstance();
      Enumeration fields = doc.fields();
      while(fields.hasMoreElements()){
        Field field = (Field)fields.nextElement();
        //System.out.println(field.name()+" -- "+field.stringValue());
        if(CLASSNAME_FIELD.equals(field.name()))
          continue;
        //�����ֶβ�����ӳ��
        if(!field.isStored())
          continue;
        //System.out.println("=========== begin to mapping ============");
        //String --> anything
          Class fieldType = getNestedPropertyType(result, field.name());
          //System.out.println(field.name()+", class = " + fieldType.getName());
          Object fieldValue = null;
          if(fieldType.equals(Date.class))
            fieldValue = new Date(Long.parseLong(field.stringValue()));
          else
            fieldValue = ConvertUtils.convert(field.stringValue(), fieldType);
          //System.out.println(fieldValue+", class = " + fieldValue.getClass().getName());
          setNestedProperty(result, field.name(), fieldValue);
      }
      results.add(result);
    }
   
    return results;
View Full Code Here

    }

    private static StandardAnalyzer analyzer = new StandardAnalyzer();
   
    protected static final Field Keyword(String name, String value) {
        return new Field(name, value, Field.Store.YES, Field.Index.UN_TOKENIZED);
  }
View Full Code Here

    protected static final Field Keyword(String name, String value) {
        return new Field(name, value, Field.Store.YES, Field.Index.UN_TOKENIZED);
  }
   
    protected static final Field Text(String name, String value){
      return new Field(name, value, Field.Store.YES, Field.Index.TOKENIZED);
    }
View Full Code Here

    protected static final Field Text(String name, String value){
      return new Field(name, value, Field.Store.YES, Field.Index.TOKENIZED);
    }
   
    protected static final Field UnStored(String name, String value){
      return new Field(name, value, Field.Store.NO, Field.Index.TOKENIZED);
    }
View Full Code Here

            }
            ## LUCENE2 end ##*/
            //## LUCENE3 begin ##
            String query = getQuery(row);
            Document doc = new Document();
            doc.add(new Field(LUCENE_FIELD_QUERY, query,
                    Field.Store.YES, Field.Index.NOT_ANALYZED));
            long time = System.currentTimeMillis();
            doc.add(new Field(LUCENE_FIELD_MODIFIED,
                    DateTools.timeToString(time, DateTools.Resolution.SECOND),
                    Field.Store.YES, Field.Index.NOT_ANALYZED));
            StatementBuilder buff = new StatementBuilder();
            for (int index : indexColumns) {
                String columnName = columns[index];
                String data = asString(row[index], columnTypes[index]);
                // column names that start with _
                // must be escaped to avoid conflicts
                // with internal field names (_DATA, _QUERY, _modified)
                if (columnName.startsWith(LUCENE_FIELD_COLUMN_PREFIX)) {
                    columnName = LUCENE_FIELD_COLUMN_PREFIX + columnName;
                }
                doc.add(new Field(columnName, data,
                        Field.Store.NO, Field.Index.ANALYZED));
                buff.appendExceptFirst(" ");
                buff.append(data);
            }
            Field.Store storeText = STORE_DOCUMENT_TEXT_IN_INDEX ?
                    Field.Store.YES : Field.Store.NO;
            doc.add(new Field(LUCENE_FIELD_DATA, buff.toString(), storeText,
                    Field.Index.ANALYZED));
            try {
                indexAccess.writer.addDocument(doc);
                indexAccess.writer.commit();
                // recreate Searcher with the IndexWriter's reader.
View Full Code Here

                long dayInMillis = beginningOfDay.getTimeInMillis();
                long timeInMillis = moment.getTime() - dayInMillis;

                // need to store channel without the '#'
                doc.add(new Field("moment", DateField.dateToString(resultSet.getTimestamp("moment")), true, true, true));
                doc.add(new Field("momentDateSort", String.valueOf(dayInMillis), false, true, false));
                doc.add(new Field("momentTimeSort", String.valueOf(timeInMillis), false, true, false));
                doc.add(new Field("botname", botname, true, true, true));
                doc.add(new Field("channel", channel, true, true, true));
                doc.add(new Field("servername", servername, true, true, true));
                doc.add(new Field("nickname", resultSet.getString("nickname"), true, true, true));
                doc.add(new Field("username", resultSet.getString("username"), true, true, true));
                doc.add(new Field("hostname", resultSet.getString("hostname"), true, true, true));
                doc.add(new Field("message", resultSet.getString("message"), true, true, true));

                try
                {
                  writer.addDocument(doc, getAnalyzer());
                }
View Full Code Here

    beginningOfDay.set(Calendar.MILLISECOND, 0);

    long dayInMillis = beginningOfDay.getTimeInMillis();
    long timeInMillis = moment.getTime() - dayInMillis;

    doc.add(new Field("moment", DateField.dateToString(moment), true, true, true));
    doc.add(new Field("momentDateSort", String.valueOf(dayInMillis), false, true, false));
    doc.add(new Field("momentTimeSort", String.valueOf(timeInMillis), false, true, false));
    doc.add(new Field("botname", botname, true, true, true));
    doc.add(new Field("channel", channelname, true, true, true));
    doc.add(new Field("servername", servername, true, true, true));
    doc.add(new Field("nickname", message.getPrefix().getNickName(), true, true, true));
    doc.add(new Field("username", message.getPrefix().getUser(), true, true, true));
    doc.add(new Field("hostname", message.getPrefix().getHost(), true, true, true));
    doc.add(new Field("message", message.getTrailing(), true, true, true));

    addDocumentToQueue(getIndexName(botname, servername, channelname), doc);
  }
View Full Code Here

    return new BoboBrowser(newIndexReader());
  }
   
  public static Field buildMetaField(String name,String val)
  {
    Field f = new Field(name,val,Field.Store.NO,Index.NOT_ANALYZED_NO_NORMS);
    f.setOmitTermFreqAndPositions(true);
    return f;
  }
View Full Code Here

   
    }
 
    public static Field buildMetaSizePayloadField(final Term term, final int size)
    {
      Field f = new Field(term.field(), new MetaTokenStream(term,size));
      return f;
    }
View Full Code Here

TOP

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

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.