On Mon, Apr 25, 2011 at 4:49 PM, Simon Wistow <si...@thegestalt.org> wrote:
> On Mon, Apr 25, 2011 at 04:34:05PM -0400, Jonathan Rochkind said:
>> This is what I do instead, to rewrite the query to mean the same thing but
>> not give the lucene query parser trouble:
>>
>> fq=( (*:* AND -type:foo) OR restriction_id:1)
>>
>> "*:*" means "everything", so (*:* AND -type:foo) means the same thing as
>> just "-type:foo", but can get around the lucene query parsers troubles.
>>
>> So that might work for you.
>
> Thanks for confirming my suspicions.
>
> Unfortunately I've tried that as well and, whilst it works
> it's also unbelievably slow (~30s query time).

It really shouldn't be that slow... how many documents are in your
index, and how many match -type:foo?

bq. Would writing my own Query Parser help here?

Nope.  That's just syntax.

If filters of the form ( (*:* AND -type:foo) OR restriction_id:1)
are much slower (to the point where it causes you problems) and
filters of the form
type:foo) OR restriction_id:1
are fast, then you could index the negation of the type field as well
(if you know all the types)

For instance, in a doc, index two type fields:
type:bar
type_not:foo

Or if "type" is multi-valued, you could index both foo and NOT_foo in
the same field.

Then you could express the filter as type_not:foo OR restriction_id:1
or
type:NOT_foo OR restriction_id:1

-Yonik
http://www.lucenerevolution.org -- Lucene/Solr User Conference, May
25-26, San Francisco

Reply via email to