2

I have an solr index with an multivalued field named colors, where all the colors stored, related to the document, like:

colors: ["blue","red"]
colors: ["blue" "brown", "green"]
colors: ["blue"]

Now I need to get only those documents, which has only one color or which only has "blue". So the solr query should return only on document, which has only one value in this multi-value filed:

colors: ["blue"]

Is there a way to do this with solr-syntax?

Thank you.

The Bndr
  • 13,204
  • 16
  • 68
  • 107
  • 3
    Not directly, so the preferred solution is to add a second field containing the count, i.e. `color_count: 1` - that will allow you to filter and index on the field just as you would with any other fields. You can use the CountFieldValuesUpdateRequestProcessor to make Solr populate this field when a document gets indexed: https://lucene.apache.org/solr/6_6_0//solr-core/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.html – MatsLindh Dec 09 '20 at 14:21

0 Answers0