Skip to content

Commit

Permalink
Adding indexordocvalue to custom query scorer
Browse files Browse the repository at this point in the history
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
  • Loading branch information
harshavamsi committed Oct 13, 2023
1 parent 292429b commit 29f79fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package org.opensearch.search.fetch.subphase.highlight;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexOrDocValuesQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.highlight.QueryScorer;
import org.apache.lucene.search.highlight.WeightedSpanTerm;
Expand Down Expand Up @@ -104,6 +105,8 @@ protected void extract(Query query, float boost, Map<String, WeightedSpanTerm> t
super.extract(((FunctionScoreQuery) query).getSubQuery(), boost, terms);
} else if (query instanceof OpenSearchToParentBlockJoinQuery) {
super.extract(((OpenSearchToParentBlockJoinQuery) query).getChildQuery(), boost, terms);
} else if (query instanceof IndexOrDocValuesQuery) {
super.extract(((IndexOrDocValuesQuery) query).getIndexQuery(), boost, terms);
} else {
super.extract(query, boost, terms);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,16 @@ public void testToQueryBooleanPrefixMultipleFields() throws IOException {
} else if (disjunct instanceof PrefixQuery) {
final PrefixQuery secondDisjunct = (PrefixQuery) disjunct;
assertThat(secondDisjunct.getPrefix(), equalTo(new Term(KEYWORD_FIELD_NAME, "foo bar")));
} else if (disjunct instanceof IndexOrDocValuesQuery) {
final IndexOrDocValuesQuery iodvqDisjunct = (IndexOrDocValuesQuery) disjunct;
assertThat(iodvqDisjunct.getIndexQuery().toString(), equalTo("mapped_string_2:foo bar*"));
} else {
throw new AssertionError();
}
assertThat(disjunct, either(instanceOf(BooleanQuery.class)).or(instanceOf(PrefixQuery.class)));
assertThat(
disjunct,
either(instanceOf(BooleanQuery.class)).or(instanceOf(PrefixQuery.class)).or(instanceOf(IndexOrDocValuesQuery.class))
);
}
}
}
Expand Down

0 comments on commit 29f79fe

Please sign in to comment.