Search in sources :

Example 81 with IntPoint

use of org.apache.lucene.document.IntPoint in project gerrit by GerritCodeReview.

the class AbstractLuceneIndex method add.

void add(Document doc, Values<V> values) {
    String name = values.getField().getName();
    FieldType<?> type = values.getField().getType();
    Store store = store(values.getField());
    if (type == FieldType.INTEGER || type == FieldType.INTEGER_RANGE) {
        for (Object value : values.getValues()) {
            Integer intValue = (Integer) value;
            if (schema.useLegacyNumericFields()) {
                doc.add(new LegacyIntField(name, intValue, store));
            } else {
                doc.add(new IntPoint(name, intValue));
                if (store == Store.YES) {
                    doc.add(new StoredField(name, intValue));
                }
            }
        }
    } else if (type == FieldType.LONG) {
        for (Object value : values.getValues()) {
            addLongField(doc, name, store, (Long) value);
        }
    } else if (type == FieldType.TIMESTAMP) {
        for (Object value : values.getValues()) {
            addLongField(doc, name, store, ((Timestamp) value).getTime());
        }
    } else if (type == FieldType.EXACT || type == FieldType.PREFIX) {
        for (Object value : values.getValues()) {
            doc.add(new StringField(name, (String) value, store));
        }
    } else if (type == FieldType.FULL_TEXT) {
        for (Object value : values.getValues()) {
            doc.add(new TextField(name, (String) value, store));
        }
    } else if (type == FieldType.STORED_ONLY) {
        for (Object value : values.getValues()) {
            doc.add(new StoredField(name, (byte[]) value));
        }
    } else {
        throw FieldType.badFieldType(type);
    }
}
Also used : IntPoint(org.apache.lucene.document.IntPoint) StoredField(org.apache.lucene.document.StoredField) StringField(org.apache.lucene.document.StringField) Store(org.apache.lucene.document.Field.Store) TextField(org.apache.lucene.document.TextField) LegacyIntField(org.apache.lucene.document.LegacyIntField)

Aggregations

IntPoint (org.apache.lucene.document.IntPoint)81 Document (org.apache.lucene.document.Document)71 Directory (org.apache.lucene.store.Directory)47 LongPoint (org.apache.lucene.document.LongPoint)30 DoublePoint (org.apache.lucene.document.DoublePoint)29 FloatPoint (org.apache.lucene.document.FloatPoint)28 StoredField (org.apache.lucene.document.StoredField)27 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)25 NumericDocValuesField (org.apache.lucene.document.NumericDocValuesField)24 IndexReader (org.apache.lucene.index.IndexReader)22 StringField (org.apache.lucene.document.StringField)21 IndexWriter (org.apache.lucene.index.IndexWriter)21 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)20 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)18 BytesRef (org.apache.lucene.util.BytesRef)18 BinaryPoint (org.apache.lucene.document.BinaryPoint)17 RAMDirectory (org.apache.lucene.store.RAMDirectory)16 Field (org.apache.lucene.document.Field)13 SortedDocValuesField (org.apache.lucene.document.SortedDocValuesField)13 IndexSearcher (org.apache.lucene.search.IndexSearcher)12