lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: query for non-existence of fields
Date Wed, 05 Oct 2011 19:28:39 GMT
MatchAllDocsQuery.

It's in the FAQ.
http://wiki.apache.org/lucene-java/LuceneFAQ#How_does_one_determine_which_documents_do_not_have_a_certain_term.3F

--
Ian.


On Wed, Oct 5, 2011 at 8:11 PM, Sam Jiang <sam.jiang@karoshealth.com> wrote:
> Hi
>
> I'm struggling to figure out a way to query for the non-existence of some
> fields. e.g. matches all documents that doesn't contain field X
>
> I tried:
>        BooleanQuery q = new BooleanQuery();
>        q.add(new BooleanClause(
>                new TermQuery(new Term("fieldName", "*")),
>                Occur.MUST_NOT));
>
> but then I realized the javadoc says it's impossible to query with a mere
> MUST_NOT clause
>
>
> A workaround I can think of is to add stub fields of name "", but this
> increases the size of the index =/
>
> any suggestions are welcome
>
> thanks
>
>
>
> --
> Sam Jiang | karoshealth
> (っ゚Д゚;)っ hidden cat here
> 7 Father David Bauer Drive, Suite 201
> Waterloo, ON, N2L 0A2, Canada
> www.karoshealth.com
>

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