Solr query - array having at least one value not in a specific list

Viewed 58

I need a way to filter query, in order to get documents containing array with at least one value not in a specific list.

For example :

{
  id:1,
  field:["dog", "cat", "bird"]
},
{
  id:2,
  field:["cat", "bird"]
},
{
  id:3,
  field:["bird"]
}

I want to filter documents which contains at least one value other than "cat" and "bird". Expected result :

{
  id:1,
  field:["dog", "cat", "bird"]
}

I've found this similar question, but the answers seems to apply only with integers values : Solr query to filter document with at least one value in array except of specified values

I can change the documents structure, add new fields, calculate them... if necessary.

Thanks for your help !

1 Answers

I've made a mistake when sorting more complex values during my tests, so it looked like the method wasn't working.

Solution :

qf=field&q=+([* TO bird} {bird TO cat} {cat TO *])

Many thanks MatsLindh

Related