Hi Jeff,

I don't know of a query parser that will allow you to acheive this.

However, if you can programmatically construct (at least a component of) your 
queries, then you may want to check out Lucene's SpanQuery functionality.

In particular, using your example, if you combine a SpanFirstQuery over a 
SpanNearQuery on "white house" (to cover the case of "white house" at the 
beginning of a field) with a SpanNearQuery over a SpanRegexQuery for 
(?!russian$) - i.e., anything but "russian" - and another SpanNearQuery on 
"white house", you may get what you want.

In a lisp-ish query-like syntax:

{or:{first:{near~0:white house}}{near~0:{regex:(?!russian)}{near~0:white house}}

<http://lucene.apache.org/java/2_3_2/api/org/apache/lucene/search/spans/SpanQuery.html>

Steve

On 08/11/2008 at 7:18 PM, Jeff French wrote:
> 
> We're trying to perform a query where if our intended search term/phrase
> is part of a specific larger phrase, we want to ignore that particular
> match, but not the entire document (unless of course there are no other
> hits with our intended term/phrase). For example, a query like:
> 
>     "white house" UNLESS "russian white house"
> 
> should not produce a match on the phrase:
> 
>     "russian white house"
> 
> but should match:
> 
>     "white house"
> 
> Where this differs from the NOT operator is that we don't want to rule
> out a document just because it contains "russian white house", we just
> want to ignore the hit, so that this phrase:
> 
>     "... in the russian white house as opposed to the american white house 
> ..."
> 
> would return the document.
> 
> Can this be accomplished using Lucene or Qsol QueryParser syntax, or do
> we need to write something custom?
> --
> View this message in context: 
> http://www.nabble.com/Query-to-ignore-certain-phrases-tp18935560p18935560.html
>  
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to