2

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
    You can do the same range searches with strings as values, as long as the values you've indexed are single tokens by themselves (i.e. the whole value is a token) – MatsLindh Jun 22 '22 at 12:43

1 Answers1

0

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