You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "anurag.jain" <an...@gmail.com> on 2013/03/14 08:48:17 UTC

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.

Re: New-Question On Search data who does not have "x" field

Posted by "anurag.jain" <an...@gmail.com>.
Hi Jack Krupansky-2

Thank you so much !!



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

Re: New-Question On Search data who does not have "x" field

Posted by Jack Krupansky <ja...@basetechnology.com>.
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.