Writing "OR -" is simply the same as "-", so the query would match documents containing category 20 and then remove all documents that had any category (including 20) specified, giving you nothing.

Try:

http://localhost:8983/search?q=*:*&wt=json&start=0&fq=category:"20"; OR (*:* -category:[* TO *])

Technically, the following should work, but there have been bugs with pure negative queries and sub-queries, so it may or may not work:

http://localhost:8983/search?q=*:*&wt=json&start=0&fq=category:"20"; OR (-category:[* TO *])

-- Jack Krupansky

-----Original Message----- From: anurag.jain
Sent: Thursday, March 14, 2013 3:48 AM
To: solr-user@lucene.apache.org
Subject: New-Question On Search data who does not have "x" field

My prev question was

I have updated 2500000 data to solr.

and some of data have "category" field and some of don't have.

for example.

{
"id":"321",
"name":"anurag",
"category":"30"
},
{
"id":"3",
"name":"john"
}

now i want to search that docs who does not have that field.
what query should like.

I got an answer.

i can use http://localhost:8983/search?q=*:*&fq=-category:[* TO *]


but now i am facing a problem. that i want to search all docs .. who does
not have category field  or category field value = 20

I wrote following query.

http://localhost:8983/search?q=*:*&wt=json&start=0&fq=category:"20"; OR
-category:[* TO *]

but it is giving me zero output.

http://localhost:8983/search?q=*:*&wt=json&start=0&fq=category:"20";  ->
output = 2689

http://localhost:8983/search?q=*:*&wt=json&start=0&fq=-category:[* TO *]  ->
output = 2644684




what is problem ... am i doing some mistakes ??



--
View this message in context: http://lucene.472066.n3.nabble.com/New-Question-On-Search-data-who-does-not-have-x-field-tp4047270.html Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to