Quel Qun
Quel Qun

Reputation: 21

Lucene/Solr unexpected query answer

I'm using Solr 4.4.0 running on Tomcat 7.0.29. The solrconfig.xlm is as-delivered (excepted for the Solr home directory of course). I could pass on the schema.xml, though I doubt this would help much, as the following will show.

If I select all documents containing "russia" in the text, which is the default field, ie if I execute the query "russia", I find only 1 document, which is correct.

If I select all documents containing "web" in the text ("web"), the result is 29, which is also correct.

If I search for all documents that do not contain "russia" ("NOT(russia)"), the result is still correct (202).

If I search for all documents that contain "web" and do not contain "russia" ("web AND NOT(russia)"), the result is, once again, correct (28, because the document containing "russia" also contains "web").

But if I search for all documents that contain "web" or do not contain "russia" ("web OR NOT(russia)"), the result is still 28, though I should get 203 matches (the whole set).

Has anyone got an explanation ??

For information, the AND and OR work correctly if I don't use a NOT somewhere in the query, i.e. : "web AND russia" --> OK "web OR russia" --> OK

Upvotes: 2

Views: 73

Answers (1)

Quel Qun
Quel Qun

Reputation: 21

I got a solution from Yonik Seeley, which is to translate the NOT(russia) into (*:* -russia), so that a positive value (: i.e. all documents) can be used to substract from (-russia). This solution works very well. I still believe that it would be a good idea to modify the parser so that the strainghtforward request "web OR NOT(russia)" would work without translation.

Upvotes: 0

Related Questions