* Set term vector flags to false for ._index_prefix field (#1901). Signed-off-by: Vesa Pehkonen <vesa.pehkonen@intel.com> * Replaced the FieldType copy ctor with ctor for the prefix field and replaced setting the field type parameters with setIndexOptions(). (#1901) Signed-off-by: Vesa Pehkonen <vesa.pehkonen@intel.com> * Added tests for term vectors. (#1901) Signed-off-by: Vesa Pehkonen <vesa.pehkonen@intel.com> * Fixed code formatting error. Signed-off-by: Vesa Pehkonen <vesa.pehkonen@intel.com> Co-authored-by: sdp <sdp@9049fa06826d.jf.intel.com>
This commit is contained in:
parent
1e6dd560df
commit
e6475255de
|
@ -205,8 +205,8 @@ public class SearchAsYouTypeFieldMapper extends ParametrizedFieldMapper {
|
|||
ft.setIndexAnalyzer(analyzers.getIndexAnalyzer());
|
||||
|
||||
// set up the prefix field
|
||||
FieldType prefixft = new FieldType(fieldType);
|
||||
prefixft.setStoreTermVectors(false);
|
||||
FieldType prefixft = new FieldType();
|
||||
prefixft.setIndexOptions(fieldType.indexOptions());
|
||||
prefixft.setOmitNorms(true);
|
||||
prefixft.setStored(false);
|
||||
final String fullName = buildFullName(context);
|
||||
|
|
|
@ -352,15 +352,30 @@ public class SearchAsYouTypeFieldMapperTests extends MapperTestCase {
|
|||
}
|
||||
|
||||
public void testTermVectors() throws IOException {
|
||||
DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "search_as_you_type").field("term_vector", "yes")));
|
||||
String[] termVectors = {
|
||||
"yes",
|
||||
"with_positions",
|
||||
"with_offsets",
|
||||
"with_positions_offsets",
|
||||
"with_positions_payloads",
|
||||
"with_positions_offsets_payloads" };
|
||||
|
||||
assertTrue(getRootFieldMapper(mapper, "field").fieldType().fieldType.storeTermVectors());
|
||||
for (String termVector : termVectors) {
|
||||
DocumentMapper mapper = createDocumentMapper(
|
||||
fieldMapping(b -> b.field("type", "search_as_you_type").field("term_vector", termVector))
|
||||
);
|
||||
|
||||
Stream.of(getShingleFieldMapper(mapper, "field._2gram"), getShingleFieldMapper(mapper, "field._3gram"))
|
||||
.forEach(m -> assertTrue("for " + m.name(), m.fieldType.storeTermVectors()));
|
||||
assertTrue(getRootFieldMapper(mapper, "field").fieldType().fieldType.storeTermVectors());
|
||||
|
||||
PrefixFieldMapper prefixFieldMapper = getPrefixFieldMapper(mapper, "field._index_prefix");
|
||||
assertFalse(prefixFieldMapper.fieldType.storeTermVectors());
|
||||
Stream.of(getShingleFieldMapper(mapper, "field._2gram"), getShingleFieldMapper(mapper, "field._3gram"))
|
||||
.forEach(m -> assertTrue("for " + m.name(), m.fieldType.storeTermVectors()));
|
||||
|
||||
PrefixFieldMapper prefixFieldMapper = getPrefixFieldMapper(mapper, "field._index_prefix");
|
||||
assertFalse(prefixFieldMapper.fieldType.storeTermVectors());
|
||||
assertFalse(prefixFieldMapper.fieldType.storeTermVectorOffsets());
|
||||
assertFalse(prefixFieldMapper.fieldType.storeTermVectorPositions());
|
||||
assertFalse(prefixFieldMapper.fieldType.storeTermVectorPayloads());
|
||||
}
|
||||
}
|
||||
|
||||
public void testNorms() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue