Skip to content

Commit

Permalink
[DataFactory] Fix TU Lucene 6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
NPi2Loup committed Jul 26, 2023
1 parent 94e015f commit 3cde223
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.SortedDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
Expand Down Expand Up @@ -73,6 +74,21 @@
* @param <D> Type d'objet
*/
final class RamLuceneIndex<D extends DtObject> {
private static final FieldType KEYWORD_TYPE_STORED = new FieldType();
private static final FieldType KEYWORD_TYPE_NOT_STORED = new FieldType();

static {
KEYWORD_TYPE_STORED.setOmitNorms(true);
KEYWORD_TYPE_STORED.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
KEYWORD_TYPE_STORED.setStored(true);
KEYWORD_TYPE_STORED.setTokenized(false);
KEYWORD_TYPE_STORED.freeze();

KEYWORD_TYPE_NOT_STORED.setOmitNorms(true);
KEYWORD_TYPE_NOT_STORED.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
KEYWORD_TYPE_NOT_STORED.setTokenized(false);
KEYWORD_TYPE_NOT_STORED.freeze();
}

//DtDefinition est non serializable
private final DtDefinition dtDefinition;
Expand Down Expand Up @@ -276,7 +292,7 @@ private static void addKeyword(
final String fieldName,
final String fieldValue,
final boolean storeValue) {
final IndexableField keywordField = new StringField(fieldName, fieldValue, storeValue ? Field.Store.YES : Field.Store.NO);
final IndexableField keywordField = new Field(fieldName, fieldValue, storeValue ? KEYWORD_TYPE_STORED : KEYWORD_TYPE_NOT_STORED);
final IndexableField sortedDocValuesField = new SortedDocValuesField(fieldName, new BytesRef(fieldValue));
document.add(keywordField);
document.add(sortedDocValuesField);
Expand Down

0 comments on commit 3cde223

Please sign in to comment.