OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

Cannot return Elasticsearch results for Content Picker Field when multiple options are selected #8793

Closed MEllis-Bethany closed 6 months ago

MEllis-Bethany commented 6 months ago

Description I'm working on a search module and trying to build it around Elasticsearch. I'm having trouble getting accurate results when filtering based on the selected items in a content picker field when the field has multiple options selected. Specifically, only the first item in the field is being indexed properly.

Data These are the related values that I have stored in the content item:

{
    "AllFieldsPart": {
        "ContentPickerListMultiple": {
            "ContentItemIds": [
                "4sjtqvw77bhfs3qz6s000s0r47",
                "4skvb8x1zq8522xjecjtnj62mx"
            ]
        }
    }
}

This is what the elastic search index looks like: image

And this is the query that I have been using:

{
    "query": {
        "bool": {
            "must": [
                {
                    "match_all": {}
                }
            ],
            "should": [
                //{
                //    "match": {
                //          "AllFieldsPart.ContentPickerListMultiple": "4sjtqvw77bhfs3qz6s000s0r47"
                //    }
                //},
                {
                    "match": {
                        "AllFieldsPart.ContentPickerListMultiple": "4skvb8x1zq8522xjecjtnj62mx"
                    }
                }
            ],
            "minimum_should_match": 1
        }
    }
}

Outcome When the commented out section of the query is included, the content item appears in the search result. But without it, no results appear. I want the content item to appear if either value is selected in the filter. I don't believe that my query is the problem, but in how the data is stored in the index.