Skip to content

Commit 723ab8f

Browse files
committed
supported field types
Signed-off-by: Anthony Leong <aj.leong623@gmail.com>
1 parent ffda262 commit 723ab8f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

server/src/main/java/org/opensearch/index/mapper/BinaryDocValuesFetcher.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
import java.util.ArrayList;
1616
import java.util.List;
1717

18+
/**
19+
* FieldValueFetcher for binary doc values
20+
*
21+
* @opensearch.internal
22+
*/
1823
public class BinaryDocValuesFetcher extends FieldValueFetcher {
1924

2025
public BinaryDocValuesFetcher(MappedFieldType mappedFieldType, String simpleName) {

server/src/test/java/org/opensearch/index/mapper/WildcardFieldMapperTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
1515
import org.apache.lucene.analysis.standard.StandardAnalyzer;
1616
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
17+
import org.apache.lucene.document.BinaryDocValuesField;
1718
import org.apache.lucene.document.Document;
1819
import org.apache.lucene.document.Field;
1920
import org.apache.lucene.document.SortedSetDocValuesField;
@@ -126,7 +127,7 @@ public void testEnableDocValues() throws IOException {
126127
IndexableField[] fields = doc.rootDoc().getFields("field");
127128
assertEquals(2, fields.length);
128129
assertEquals(DocValuesType.NONE, fields[0].fieldType().docValuesType());
129-
assertEquals(DocValuesType.SORTED_SET, fields[1].fieldType().docValuesType());
130+
assertEquals(DocValuesType.BINARY, fields[1].fieldType().docValuesType());
130131

131132
mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "wildcard")));
132133
doc = mapper.parse(source(b -> b.field("field", "1234")));
@@ -214,7 +215,7 @@ public void testNormalizer() throws IOException {
214215
assertEquals(new BytesRef("abc"), fields[1].binaryValue());
215216
fieldType = fields[1].fieldType();
216217
assertEquals(IndexOptions.NONE, fieldType.indexOptions());
217-
assertEquals(DocValuesType.SORTED_SET, fieldType.docValuesType());
218+
assertEquals(DocValuesType.BINARY, fieldType.docValuesType());
218219
}
219220

220221
public void testNullValue() throws IOException {
@@ -251,7 +252,7 @@ public void testNullValue() throws IOException {
251252
);
252253
assertEquals(new BytesRef("uri"), fields[1].binaryValue());
253254
assertEquals(IndexOptions.NONE, fields[1].fieldType().indexOptions());
254-
assertEquals(DocValuesType.SORTED_SET, fields[1].fieldType().docValuesType());
255+
assertEquals(DocValuesType.BINARY, fields[1].fieldType().docValuesType());
255256
}
256257

257258
public void testDefaults() throws Exception {
@@ -386,7 +387,7 @@ private Document createDocument(WildcardFieldMapper mapper, String value) throws
386387
NamedAnalyzer normalizer = mapper.fieldType().normalizer();
387388
value = normalizeValue(normalizer, FIELD_NAME, value);
388389
final BytesRef binaryValue = new BytesRef(value);
389-
doc.add(new SortedSetDocValuesField(FIELD_NAME, binaryValue));
390+
doc.add(new BinaryDocValuesField(FIELD_NAME, binaryValue));
390391
return doc;
391392
}
392393
}

test/framework/src/main/java/org/opensearch/search/aggregations/AggregatorTestCase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
import org.opensearch.index.mapper.SemanticVersionFieldMapper;
124124
import org.opensearch.index.mapper.StarTreeMapper;
125125
import org.opensearch.index.mapper.TextFieldMapper;
126+
import org.opensearch.index.mapper.WildcardFieldMapper;
126127
import org.opensearch.index.query.QueryBuilder;
127128
import org.opensearch.index.query.QueryShardContext;
128129
import org.opensearch.index.shard.IndexShard;
@@ -1128,7 +1129,7 @@ private void writeTestDoc(MappedFieldType fieldType, String fieldName, RandomInd
11281129
doc.add(new SortedNumericDocValuesField(fieldName, v));
11291130

11301131
} else if (vst.equals(CoreValuesSourceType.BYTES)) {
1131-
if (typeName.equals(BinaryFieldMapper.CONTENT_TYPE)) {
1132+
if (typeName.equals(BinaryFieldMapper.CONTENT_TYPE) || typeName.equals(WildcardFieldMapper.CONTENT_TYPE)) {
11321133
doc.add(new BinaryFieldMapper.CustomBinaryDocValuesField(fieldName, new BytesRef("a").bytes));
11331134
json = "{ \"" + fieldName + "\" : \"a\" }";
11341135
} else {

0 commit comments

Comments
 (0)