Ordered Proximity searching, does it exist?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Ordered Proximity searching, does it exist?

Adam-72

Dear Lucene Users,

Is there a way or has someone been able to implement an ordered proximity search. Lucene currently uses the "word1 word2"~5 query to find tokens that are within 5 words of each other in any order. What I've been asked to do is find only the results that are for instance within 5 words of each other in the order the query was written.

For a scenario like


text:"blah blah blah. Section 1 of Primary Act 1976, s1. Dogs Act 1999, s3 blah blah blah"


Say  I wanted to find the Dogs Act Section 1 using text:"dogs act s1"~5 query would give the above record when it wasn't in context. This is the reason for wanting results in order to stop these incorrect results.


Any help would be greatly appreciated.

R
Adam



_________________________________________________________________
Be one of the first to try Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Ordered Proximity searching, does it exist?

Erik Hatcher

On Nov 20, 2006, at 11:20 PM, Adam wrote:

>
> Dear Lucene Users,
>
> Is there a way or has someone been able to implement an ordered  
> proximity search. Lucene currently uses the "word1 word2"~5 query  
> to find tokens that are within 5 words of each other in any order.  
> What I've been asked to do is find only the results that are for  
> instance within 5 words of each other in the order the query was  
> written.

Yup... SpanNearQuery supports ordered and unordered proximity.  
PhraseQuery does not, though.  QueryParser will only create a  
PhraseQuery though, so you'll need to subclass QueryParser to add  
this functionality.  There is an example of this in the free code of  
Lucene in Action - http://www.lucenebook.com

        Erik


>
> For a scenario like
>
>
> text:"blah blah blah. Section 1 of Primary Act 1976, s1. Dogs Act  
> 1999, s3 blah blah blah"
>
>
> Say  I wanted to find the Dogs Act Section 1 using text:"dogs act  
> s1"~5 query would give the above record when it wasn't in context.  
> This is the reason for wanting results in order to stop these  
> incorrect results.
>
>
> Any help would be greatly appreciated.
>
> R
> Adam
>
>
>
> _________________________________________________________________
> Be one of the first to try Windows Live Mail.
> http://ideas.live.com/programpage.aspx?versionId=5d21c51a- 
> b161-4314-9b0e-4911fb2b2e6d
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]