Agree on span query.

Might try SpanNotQuery("record", "type", 0, 1)...

Find "record" but not if "type" comes one word after "record".

<warning type="self_promotion">If you use LUCENE-5205's SpanQueryParser: 
"record type"!~0,1</warning>

-----Original Message-----
From: Trejkaz [mailto:trej...@trypticon.org] 
Sent: Thursday, July 23, 2015 11:29 PM
To: Lucene Users Mailing List <java-user@lucene.apache.org>
Subject: Re: ignore a match in a query

On Fri, Jul 24, 2015 at 2:53 AM, Fielder, Todd Patrick
<tpfi...@sandia.gov> wrote:
> Hi,
> I'm wondering if there is a way to ignore a match in a query?  For example, I 
> have two strings
>
> 1)      "Record type: record"
>
> 2)      "Record type: cd"
>
> I do not want the text "record type" to match, so searching for the text 
> "record" should return string 1 and not string 2.  I can't say "NOT Record 
> Type" because then neither string would match

Sounds like a span query:
  1. SpanTermQuery to search for "record"
  2. SpanNearQuery containing SpanTermQuery for "record" immediately
in front of a SpanTermQuery for "type"
  3. SpanNotQuery to exclude the latter from the former.

TX

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


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

Reply via email to