lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Jiang <>
Subject query for non-existence of fields
Date Wed, 05 Oct 2011 19:11:02 GMT

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", "*")),

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


Sam Jiang | karoshealth
(っ゚Д゚;)っ hidden cat here
7 Father David Bauer Drive, Suite 201
Waterloo, ON, N2L 0A2, Canada

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message