0
votes

I'm using Lucene 7.4 to index & store fields. While looking at the API I noticed that there were provided field classes for indexing most data types(Byte, Integer, Long, Double, Float, String) but no field class for Shorts. https://lucene.apache.org/core/7_4_0/core/org/apache/lucene/document/Field.html

My understanding is that I can use the default Field class to create a 'custom' field type for Shorts but I'm unsure how to construct it properly as there is no constructor that takes in my field type:

FieldType shortFieldType = new FieldType();
shortFieldType.setStored(true);
shortFieldType.setTokenized(false);
shortFieldType.setIndexOptions(IndexOptions.DOCS);
shortFieldType.setDocValuesType(DocValuesType.NUMERIC);

Field shortField = new Field("fieldName", ???, shortFieldType);
shortField.setShortValue((Short) shortValue);
document.add(shortField);

I am also curious why there is no ShortPoint class defined in the API. I could probably get away with using an IntPoint but I would like to avoid wasted space. All previous research I did referred to earlier versions of Lucene that had different class constructs.

1

1 Answers

1
votes

The codec already compresses the values when they are written to the index, so there will be no difference, in terms of size of the index, using an IntPoint for short values vs implementing a ShortPoint.