lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: nested phrase queries
Date Thu, 06 Apr 2006 13:56:46 GMT

On Apr 6, 2006, at 8:47 AM, Michael Dodson wrote:
> Can phrase queries be nested the same way boolean queries can be  
> nested?

Yes... using SpanNearQuery instead of PhraseQuery.

> I want a user query to be translated into a boolean query (say, x  
> AND (y OR z)), and I want  those terms to be within a certain  
> distance of each other (approximately within the same sentence, so  
> the slop would be about 7).   I then want to find documents where  
> that phrase is within a certain distance of another term (in this  
> case an image name).  So in pseudo code I would have something like
>
> PhraseQuery query1
> Set slop to 7
>
> PhraseQuery query2
> Set slop to 50
>
> Add boolean terms to query1
> Add query1 and imageName to query2
>
> Search
>
> I think I could break down my initial boolean query and turn query1  
> into two phrase queries which are OR'ed together (so have query1a  
> with "x AND y" with slop 7, and query1b with "x AND z" and slop 7,  
> both added to a BooleanQuery) but I still need to combine that  
> query with the image name in query2.

QueryParser itself does not support the SpanQuery family, but the  
surround query parser (see contrib/surround in the codebase) does  
using an alternate syntax.  So depending on your needs, you may need  
to create some sort of parser to allow humans to enter such queries.

	Erik


---------------------------------------------------------------------
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