lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <>
Subject Re: matching only empty fields
Date Sat, 29 May 2010 14:36:22 GMT
On Sat, May 29, 2010 at 10:01 AM, Lukas Kahwe Smith <> wrote:
> Hi,
> I have implemented a facet search, where users essentially select what should not be
included. I do this by constructing an fq filter where I match for the deselected items that
I then negate:
>            $fq = "{!tag=dt}!($fq)";
>            $criteria->addParam('fq', $fq);
> Now in some cases the field the user is deselecting is actually an empty string.
> For example go to the below address and open the "legal value" section. there is an option
"none" there, which is actually an empty string.
> The field itself is just an untokenized string. Of course I could just turn an empty
string into "none" at index time, but I am wondering how to do it in general :)
> I tried using just "" or ["" TO ""] to match for empty strings, but this matches everything
and due to the negation removes everything.

Hmmm, if this is on a String field, it seemed to work for me.

The raw query parser would also work (it skips analysis):
http://localhost:8983/solr/select?debugQuery=on&q={!raw f=foo_s}

But yes, indexing differently may be easier for you... either by
indexing a special token for _NONE_
or by leaving out the value completely (not indexing it), and using
facet.missing=true and filtering for none via fq=-myfield:[* TO *]


View raw message