lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Shannon" <>
Subject Negative Match
Date Thu, 10 Feb 2005 21:06:11 GMT
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",
         BooleanQuery typeNegAll = new BooleanQuery();
        Query allResults = new WildcardQuery(new Term("kcfileupload", "*"));
        IndexSearcher searcher = new IndexSearcher(fsDir);
        BooleanClause clause = new BooleanClause(negativeMatch, false,
        typeNegAll.add(allResults, true, false);
        Hits hits =;

With the little testing I have done this *seems* to work. Does anyone see a
problem with this approach?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message