Thanks Eric. This is indeed the way to go.

----- Original Message ----- 
From: "Erik Hatcher" <[EMAIL PROTECTED]>
To: "Lucene Users List" <lucene-user@jakarta.apache.org>
Sent: Friday, February 11, 2005 10:25 AM
Subject: Re: Negative Match


> 
> On Feb 11, 2005, at 9:52 AM, Luke Shannon wrote:
> 
> > Hey Erik;
> >
> > The problem with that approach is I get document that don't have a
> > kcfileupload field. This makes sense because these documents don't 
> > match the
> > prohibited
> > clause, but doesn't fit with the requirements of the system.
> 
> Ok, so instead of using the dummy field with a single dummy value, use 
> a dummy field to list the field names.  
> Field.Keyword("fields","kcfileupload"), but only for the documents that 
> should have it, of course.  Then use a query like (using QueryParser 
> syntax, but do it with the API as you have since QueryParser doesn't 
> support leading wildcards):
> 
> +fields:kcfileupload -kcfileupload:*jpg*
> 
> Again, your approach is risky with term expansion.  Get more than 1,024 
> unique kcfileupload values and you'll see!
> 
> Erik
> 
> 
> >
> > What I like best about this approach is it doesn't require a filter. 
> > The
> > system I integrate with is presently designed to accept a query 
> > object. I
> > wasn't looking forward to having to add the possibility that queries 
> > might
> > require filters. I may have to still do this, but for now I would like 
> > to
> > try this and see how it goes.
> >
> > Thanks,
> >
> > Luke
> >
> > ----- Original Message -----
> > From: "Erik Hatcher" <[EMAIL PROTECTED]>
> > To: "Lucene Users List" <lucene-user@jakarta.apache.org>
> > Sent: Thursday, February 10, 2005 7:23 PM
> > Subject: Re: Negative Match
> >
> >
> >>
> >> On Feb 10, 2005, at 4:06 PM, Luke Shannon wrote:
> >>
> >>> I think I found a pretty good way to do a negative match.
> >>>
> >>> In this query I am looking for all the Documents that have a
> >>> kcfileupload
> >>> field with any value except for jpg.
> >>>
> >>>         Query negativeMatch = new WildcardQuery(new
> >>> Term("kcfileupload",
> >>> "*jpg*"));
> >>>          BooleanQuery typeNegAll = new BooleanQuery();
> >>>         Query allResults = new WildcardQuery(new Term("kcfileupload",
> >>> "*"));
> >>>         IndexSearcher searcher = new IndexSearcher(fsDir);
> >>>         BooleanClause clause = new BooleanClause(negativeMatch, 
> >>> false,
> >>> true);
> >>>         typeNegAll.add(allResults, true, false);
> >>>         typeNegAll.add(clause);
> >>>         Hits hits = searcher.search(typeNegAll);
> >>>
> >>> With the little testing I have done this *seems* to work. Does anyone
> >>> see a
> >>> problem with this approach?
> >>
> >> Sure.... do you realize what WildcardQuery does under the covers?  It
> >> literally expands to a BooleanQuery for all terms that match the
> >> pattern.  There is an adjustable limit built-in of 1,024 clauses to
> >> BooleanQuery.  You obviously have not hit that limit ... yet!
> >>
> >> You're better off using the advice offered on this thread
> >> previously.... create a single dummy field with a fixed value for all
> >> documents.  Combine a TermQuery for that dummy value with a prohibited
> >> clause like y our negativeMatch above.
> >>
> >> Erik
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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

Reply via email to