lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: Can Span Queries contain boolean, prefix and other component queries?
Date Mon, 05 Sep 2005 07:05:48 GMT
On Monday 05 September 2005 04:38, Chris Hostetter wrote:
> 
> : >>[Query]
> : >>"Napol* Dynamite" near "film|movie"
> 
> : >This can be done using nested SpanNearQuery's and SpanOrQuery's.
> : >A PhrasePrefixQuery can not be used as a SpanQuery.
> 
> I've never really looked at SpanQueries very hard, but this thread got me
> a bit curious.
> 
> Looking over the docs and the code, it seems that *IF* there were a
> "SpanPrefixQuery" then the query could be expressed as...
> 
>   new SpanNearQuery(new SPanQuery[] {
>       new SpanNearQuery((new SpanQuery[] {
>          new SpanPrefixQuery(new Term(f, "Napol")),
>          new SpanTermQuery(new Term(f,"Dynamite"))
>          },
>         0, true
>       ),
>       new SpanOrQuery(new SPanQuery[] {
>          new SpanTermQuery(new Term(f,"film")),
>          new SpanTermQUery(new Term(f,"movie))
>          }
>       )
>     },
>     MAX_INT, false
>    )
> 
> The question then becomes, can a SpanPrefixQuery exist?

Sure.
 
> looking at the code for SpanTermQuery, it seems like it should be possible
> to write a subclass which redefines the getSPans() method to return a Span
> which not only maintains a TermPosition, but also a TermEnum which
> iterates over all terms which match the prefix -- the TermPositions
> iterator loop would be reset as many times as the TermEnum found
> usable terms.
> 
> Am I missing something about the way Spans work? ... Is what I'm
> suggesting possile/practicle, or is there a reason it doesn't allready
> exist?

The mechanics of such a SpanPrefixQuery is in the surround query language
in the SrndPrefixQuery class and its superclasses.
These classes also contain the mechanics of OR'ing the terms together
in case the prefix query term is not a subquery of a distance operator.

Kind regards,
Paul Elschot


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message