Skip to content

Commit

Permalink
fixing queryBuilderTests
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Dec 19, 2023
1 parent ec100b1 commit 31d32b8
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,9 +122,15 @@ public void testStoringQueryBuilders() throws IOException {
CheckedFunction<Integer, Query, IOException> 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());
}
}
}
Expand Down

0 comments on commit 31d32b8

Please sign in to comment.