On Sat, May 29, 2010 at 10:01 AM, Lukas Kahwe Smith <m...@pooteeweet.org> 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. > http://search.un-informed.org/search?q=malaria&=&tm=any&s=Search > > 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. http://localhost:8983/solr/select?debugQuery=on&q=foo_s:"" 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 *] -Yonik http://www.lucidimagination.com