Reputation: 1279
Is it possible to create a solr query where only documents are returned which have more than one entries in a multi valued field. For example:
docs: [
{
id: 1,
myfield: ["hello word", "hello stackoverflow"]
},
{
id: 2,
myfield: ["hello word"]
}
]
And my naive sample query just for explanation what I want:
/select?q=count(myfield.length, 'eq', 2)
Upvotes: 2
Views: 3380
Reputation: 5005
Yes it is but not "out of the box". A solution in order to achieve what you're looking for is to use CountFieldValuesUpdateProcessorFactory along with a new field called in your case myfield_count. For instance:
docs: [
{
id: 1,
myfield: ["hello word", "hello stackoverflow"]
myfield_count: 2
},
{
id: 2,
myfield: ["hello word"]
myfield_count: 1
}
]
After that you can simply use a boolean function in order to filter or score for myfield_count>1.
Upvotes: 2