Search code examples
searchsolrnosqllucene

Filter Solr query by field


I've got a large set of records like this in my index, and what I'm trying to do is to find the objects by SUB property, for example if I want to filter by sub = "5 7 8 10 820" it should result in returning in objects B and C, because they both have 5, 7, 8, 10 and 820 in their SUB property.

To generalize object's sub should contain all of the values (5,7,8,10,820) passed in filter.

Object A has only 5, 7 and 8. Therefore it doesn't satisfy the filter.

Object B has 5,7,8,10,820 in its sub property, therefore it satisfies the filter

as well as Object C does.

How can I fix my query to achieve such behavior?

This is my current query which returns what I think is all of the occurrences of the filter in objects properties:

q=*:*&rows=100&start=0&sort=id+asc&fq=%2Bsub:5+7+8+10+820

Object A: {
        "id":"ke131j-nan139-1239Mzf-sazr",
        "sub":"0 1 3 4 5 7 8"
         etc...
}

Object B: {
        "id":"ke131j-1239Mzf-nan139-sacr",
        "sub":"5 7 8 9 10 517 820 1121 1124"
         etc...
}

Object C: {
        "id":"nan139-1239Mzf-sazr-ke131j",
        "sub":"5 7 8 10 11 15 783 820 825 921 924"
         etc...
}

Solution

  • The answer from the comment was helpful, q=sub:(5 AND 7 AND 8 AND 10 AND 820), worked