Skip to content

Percolator keyword fields should not store norms #58899

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

Merged
merged 2 commits into from
Jul 2, 2020
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 @@ -400,6 +400,7 @@ static void createQueryBuilderField(Version indexVersion, BinaryFieldMapper qbFi
private static final FieldType INDEXED_KEYWORD = new FieldType();
static {
INDEXED_KEYWORD.setTokenized(false);
INDEXED_KEYWORD.setOmitNorms(true);
INDEXED_KEYWORD.setIndexOptions(IndexOptions.DOCS);
INDEXED_KEYWORD.freeze();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,11 @@ public void testNestedPercolatorField() throws Exception {
.endObject().endObject()),
XContentType.JSON));
assertThat(doc.rootDoc().getFields().size(), equalTo(12)); // also includes all other meta fields
BytesRef queryBuilderAsBytes = doc.rootDoc().getField("object_field.query_field.query_builder_field").binaryValue();
IndexableField queryBuilderField = doc.rootDoc().getField("object_field.query_field.query_builder_field");
assertTrue(queryBuilderField.fieldType().omitNorms());
IndexableField extractionResultField = doc.rootDoc().getField("object_field.query_field.extraction_result");
assertTrue(extractionResultField.fieldType().omitNorms());
BytesRef queryBuilderAsBytes = queryBuilderField.binaryValue();
assertQueryBuilder(queryBuilderAsBytes, queryBuilder);

doc = mapperService.documentMapper().parse(new SourceToParse("test", "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.elasticsearch.index.mapper;

import com.carrotsearch.hppc.ObjectArrayList;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.DocValuesFieldExistsQuery;
Expand Down Expand Up @@ -59,6 +59,7 @@ public static class Defaults {

static {
FIELD_TYPE.setIndexOptions(IndexOptions.NONE);
FIELD_TYPE.setOmitNorms(true);
FIELD_TYPE.freeze();
}
}
Expand Down Expand Up @@ -188,7 +189,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
return;
}
if (fieldType.stored()) {
context.doc().add(new Field(fieldType().name(), value, fieldType));
context.doc().add(new StoredField(fieldType().name(), value));
}

if (fieldType().hasDocValues()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public abstract class CustomDocValuesField implements IndexableField {
public static final FieldType TYPE = new FieldType();
static {
TYPE.setDocValuesType(DocValuesType.BINARY);
TYPE.setOmitNorms(true);
TYPE.freeze();
}

Expand Down