You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Ninad Raut <hb...@gmail.com> on 2009/08/18 14:28:50 UTC

Proximity Search

Hi,
I want to count the words between two significant words like "shell" and
"petroleum". Or want to write a query to find all the documents where the
content has "shell" and "petroleum" in close proximity of less than 10 words
between them.
Can such quries be created in Solr?
Regards,
Ninad Raut.

Re: Proximity Search

Posted by Erik Hatcher <er...@gmail.com>.
On Aug 18, 2009, at 8:28 AM, Ninad Raut wrote:

> Hi,
> I want to count the words between two significant words like "shell"  
> and
> "petroleum". Or want to write a query to find all the documents  
> where the
> content has "shell" and "petroleum" in close proximity of less than  
> 10 words
> between them.
> Can such quries be created in Solr?

Yes, this is known as a "sloppy" phrase query.  Using Solr's standard  
query parser, a query of "some phrase" within quotes makes an exact  
phrase query.  Using "some words"~10 matches when the field has those  
words within that distance of term positions.

	Erik


Re: Proximity Search

Posted by Toby Cole <to...@semantico.com>.
See the Lucene query parser syntax documentation:
	http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Proximity%20Searches

basically... "shell petroleum"~10 should do the trick (if you're using  
a standard request handler, can't remember if dismax supports  
proximity).

On 18 Aug 2009, at 13:28, Ninad Raut wrote:

> Hi,
> I want to count the words between two significant words like "shell"  
> and
> "petroleum". Or want to write a query to find all the documents  
> where the
> content has "shell" and "petroleum" in close proximity of less than  
> 10 words
> between them.
> Can such quries be created in Solr?
> Regards,
> Ninad Raut.

--

Toby Cole
Software Engineer, Semantico Limited
<to...@semantico.com> <tel:+44 1273 358 238>
Registered in England and Wales no. 03841410, VAT no. GB-744614334.
Registered office Lees House, 21-23 Dyke Road, Brighton BN1 3FE, UK.

Check out all our latest news and thinking on the Discovery blog
http://blogs.semantico.com/discovery-blog/