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 Ian Vink <ia...@gmail.com> on 2009/02/19 13:19:28 UTC

"Near" force in query server side?

Once my app gets the query string from the user, is there a way to tell the
query engine to only return documents where these words are at most 5 words
apart? I can't tell the user to change their query, I have to do it server
side.
Is so do I have to add anything to my index to let Lucene know about
positions of the terms when it indexes?

Thanks,
Ian Vink
http://BahaiResearch.com

Re: "Near" force in query server side?

Posted by Matt Ronge <mr...@mronge.com>.
On Feb 19, 2009, at 6:19 AM, Ian Vink wrote:

> Once my app gets the query string from the user, is there a way to  
> tell the
> query engine to only return documents where these words are at most  
> 5 words
> apart? I can't tell the user to change their query, I have to do it  
> server
> side.

I would suggest using either a phrase query with a slop, or try out  
the SpanQueries.

>
> Is so do I have to add anything to my index to let Lucene know about
> positions of the terms when it indexes?

Nope, that information is there by default.
--
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


Re: "Near" force in query server side?

Posted by Grant Ingersoll <gs...@apache.org>.
You will likely need to create n-grams from the user query and from  
that construct a sloppy PhraseQuery.

There is an n-gram Filter in the contrib/analysis package (I think it  
is called the ShingleFilter)


On Feb 19, 2009, at 7:19 AM, Ian Vink wrote:

> Once my app gets the query string from the user, is there a way to  
> tell the
> query engine to only return documents where these words are at most  
> 5 words
> apart? I can't tell the user to change their query, I have to do it  
> server
> side.
> Is so do I have to add anything to my index to let Lucene know about
> positions of the terms when it indexes?
>
> Thanks,
> Ian Vink
> http://BahaiResearch.com

--------------------------
Grant Ingersoll
http://www.lucidimagination.com/

Search the Lucene ecosystem (Lucene/Solr/Nutch/Mahout/Tika/Droids)  
using Solr/Lucene:
http://www.lucidimagination.com/search


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