Skip to content

Commit

Permalink
Fix tests for term and terms changes
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 fd22221 commit a843bf4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@

package org.opensearch.index.mapper;

import org.apache.lucene.document.SortedNumericDocValuesField;
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BoostQuery;
import org.apache.lucene.search.IndexOrDocValuesQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.BytesRef;
import org.opensearch.common.xcontent.XContentFactory;
Expand All @@ -46,6 +50,7 @@
import org.opensearch.index.mapper.ParseContext.Document;

import java.io.IOException;
import java.util.SortedSet;

public class BooleanFieldMapperTests extends MapperTestCase {

Expand Down Expand Up @@ -206,7 +211,7 @@ public void testBoosts() throws Exception {
}));

MappedFieldType ft = mapperService.fieldType("field");
assertEquals(new BoostQuery(new TermQuery(new Term("field", "T")), 2.0f), ft.termQuery("true", null));
assertEquals(new IndexOrDocValuesQuery(new BoostQuery(new TermQuery(new Term("field", "T")), 2.0f), SortedNumericDocValuesField.newSlowExactQuery("field", 1)), ft.termQuery("true", null));
assertParseMaximalWarnings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import org.apache.lucene.index.Term;
import org.apache.lucene.search.AutomatonQuery;
import org.apache.lucene.search.IndexOrDocValuesQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.PointRangeQuery;
import org.apache.lucene.search.Query;
Expand Down Expand Up @@ -112,6 +113,7 @@ protected void doAssertLuceneQuery(TermQueryBuilder queryBuilder, Query query, Q
either(instanceOf(TermQuery.class)).or(instanceOf(PointRangeQuery.class))
.or(instanceOf(MatchNoDocsQuery.class))
.or(instanceOf(AutomatonQuery.class))
.or(instanceOf(IndexOrDocValuesQuery.class))
);
MappedFieldType mapper = context.fieldMapper(queryBuilder.fieldName());
if (query instanceof TermQuery) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.IndexOrDocValuesQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.PointInSetQuery;
import org.apache.lucene.search.Query;
Expand Down Expand Up @@ -135,6 +136,7 @@ protected void doAssertLuceneQuery(TermsQueryBuilder queryBuilder, Query query,
either(instanceOf(TermInSetQuery.class)).or(instanceOf(PointInSetQuery.class))
.or(instanceOf(ConstantScoreQuery.class))
.or(instanceOf(MatchNoDocsQuery.class))
.or(instanceOf(IndexOrDocValuesQuery.class))
);
if (query instanceof ConstantScoreQuery) {
assertThat(((ConstantScoreQuery) query).getQuery(), instanceOf(BooleanQuery.class));
Expand Down

0 comments on commit a843bf4

Please sign in to comment.