33import org .apache .lucene .index .LeafReaderContext ;
44import org .apache .lucene .index .Term ;
55import org .apache .lucene .index .TermStates ;
6+ import org .apache .lucene .queries .function .FunctionScoreQuery ;
67import org .apache .lucene .queryparser .flexible .core .QueryNodeException ;
78import org .apache .lucene .queryparser .flexible .core .messages .QueryParserMessages ;
89import org .apache .lucene .queryparser .flexible .messages .MessageImpl ;
@@ -48,23 +49,31 @@ public SpanQuery getSpanQuery(SpanConverterContainer container)
4849 return new EmptySpanQuery (container .query );
4950 } else if (q instanceof SynonymQuery ) {
5051 return wrapBoost (convertSynonymToSpan (container ), boost );
51- } else {
52+ } else if (q instanceof FunctionScoreQuery functionScoreQuery ) {
53+ container .query = functionScoreQuery .getWrappedQuery ();
54+ return getSpanQuery (container );
55+ } else if (q instanceof BoostQuery boostQuery ) {
56+ container .query = boostQuery .getQuery ();
57+ return getSpanQuery (container );
58+ } else if (q instanceof ConstantScoreQuery constantScoreQuery ) {
59+ container .query = constantScoreQuery .getQuery ();
60+ return getSpanQuery (container );
61+ }
5262
53- SpanQuery wrapped = wrapNonConvertible (container );
54- if (wrapped != null )
55- return wrapped ;
63+ SpanQuery wrapped = wrapNonConvertible (container );
64+ if (wrapped != null )
65+ return wrapped ;
5666
57- throw new QueryNodeException (new MessageImpl (
58- QueryParserMessages .LUCENE_QUERY_CONVERSION_ERROR , q .toString (),
59- "(yet) Unsupported clause inside span query: "
60- + q .getClass ().getName ()));
61- }
67+ throw new QueryNodeException (new MessageImpl (
68+ QueryParserMessages .LUCENE_QUERY_CONVERSION_ERROR , q .toString (),
69+ "(yet) Unsupported clause inside span query: "
70+ + q .getClass ().getName ()));
6271 }
6372
6473 private SpanQuery convertDisjunctionQuery (SpanConverterContainer container ) throws QueryNodeException {
6574 DisjunctionMaxQuery q = (DisjunctionMaxQuery ) container .query ;
6675 Collection <Query > clauses = q .getDisjuncts ();
67- if (clauses .size () == 0 ) {
76+ if (clauses .isEmpty () ) {
6877 container .query = new MatchNoDocsQuery ();
6978 return getSpanQuery (container );
7079 } else if (clauses .size () == 1 ) {
@@ -83,7 +92,7 @@ private SpanQuery convertDisjunctionQuery(SpanConverterContainer container) thro
8392 }
8493
8594 private SpanQuery wrapBoost (SpanQuery q , float boost ) {
86- if (Math . abs (boost - 1.0f ) < 1e-6f ) {
95+ if (Float . compare (boost , 1f ) == 0 ) {
8796 return q ;
8897 }
8998
0 commit comments