Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set term vector flags to false for ._index_prefix field (#1901). #3119

Merged
merged 4 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ public SearchAsYouTypeFieldMapper build(Mapper.BuilderContext context) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,30 @@ public void testIndex() throws IOException {
}

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" };

for (String termVector : termVectors) {
DocumentMapper mapper = createDocumentMapper(
fieldMapping(b -> b.field("type", "search_as_you_type").field("term_vector", termVector))
);

assertTrue(getRootFieldMapper(mapper, "field").fieldType().fieldType.storeTermVectors());
assertTrue(getRootFieldMapper(mapper, "field").fieldType().fieldType.storeTermVectors());

Stream.of(getShingleFieldMapper(mapper, "field._2gram"), getShingleFieldMapper(mapper, "field._3gram"))
.forEach(m -> assertTrue("for " + m.name(), m.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());
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 {
Expand Down