khalid_seddeko
khalid_seddeko

Reputation: 41

I want to do a solr search to see if a dynamic field exists or not

I want to do a solr search to see if a dynamic field exists or not.

Example:

Doc 1 {
    Id: 111
    Name: good
    Tag_100_is: lsdkl
}


Doc 1 {
    Id: 2
    Name: not good
}

I want a query to retrieve doc 1.

Thank you in advance.

Upvotes: 3

Views: 6413

Answers (1)

MatsLindh
MatsLindh

Reputation: 52792

To query for whether a field exists or not, use field:[* TO *]. So in this case, you should get the document you want by using the query Tag_100_is:[* TO *].

If you want to get the document without the field, you'll have to invert the query (we start with *:* which are "all documents", then remove the documents that have the field):

q=*:* -Tag_100_is:[* TO *]

Upvotes: 3

Related Questions