You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Tim Williams <wi...@gmail.com> on 2009/02/25 21:52:13 UTC
term position in phrase query using queryparser
Is there a syntax to set the term position in a query built with
queryparser? For example, I would like something like:
PhraseQuery q = new PhraseQuery();
q.add(t1, 0);
q.add(t2, 0);
q.setSlop(0);
As I understand it, the slop defaults to 0, but I don't know how to
search for basically two tokens at the same term position using the
queryparser syntax.
Thanks,
--tim
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: term position in phrase query using queryparser
Posted by Matt Ronge <mr...@mronge.com>.
On Feb 25, 2009, at 2:52 PM, Tim Williams wrote:
> Is there a syntax to set the term position in a query built with
> queryparser? For example, I would like something like:
>
> PhraseQuery q = new PhraseQuery();
> q.add(t1, 0);
> q.add(t2, 0);
> q.setSlop(0);
>
> As I understand it, the slop defaults to 0, but I don't know how to
> search for basically two tokens at the same term position using the
> queryparser syntax.
I don't think this is available from the QueryParser. You could make a
subclass that does this for the phrase query syntax. So if you have
something like "term1 term2" then you can build your own Query and
return it, but then you can't use phrase queries anymore... Either
that or do your own parser...
--
Matt Ronge
mronge@mronge.com
http://www.mronge.com
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org