From 31d32b837e77c3847bdf3fc52325fa2017ba23df Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Tue, 19 Dec 2023 10:16:39 -0800 Subject: [PATCH] fixing queryBuilderTests Signed-off-by: Harsha Vamsi Kalluri --- .../percolator/QueryBuilderStoreTests.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java index 340d359f85523..23be40bdb66a3 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java @@ -38,6 +38,7 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.NoMergePolicy; +import org.apache.lucene.search.IndexOrDocValuesQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.Directory; @@ -121,9 +122,15 @@ public void testStoringQueryBuilders() throws IOException { CheckedFunction queries = queryStore.getQueries(leafContext); assertEquals(queryBuilders.length, leafContext.reader().numDocs()); for (int i = 0; i < queryBuilders.length; i++) { - TermQuery query = (TermQuery) queries.apply(i); - assertEquals(queryBuilders[i].fieldName(), query.getTerm().field()); - assertEquals(queryBuilders[i].value(), query.getTerm().text()); + TermQuery termQuery; + if (fieldMapper.fieldType().typeName().equals("binary")) { + IndexOrDocValuesQuery query = (IndexOrDocValuesQuery) queries.apply(i); + termQuery = (TermQuery) query.getIndexQuery(); + } else { + termQuery = (TermQuery) queries.apply(i); + } + assertEquals(queryBuilders[i].fieldName(), termQuery.getTerm().field()); + assertEquals(queryBuilders[i].value(), termQuery.getTerm().text()); } } }