OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

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

Open MEllis-Bethany opened this issue 1 year ago • 4 comments

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.

MEllis-Bethany avatar May 06 '24 12:05 MEllis-Bethany

Hmm, both (all) IDs should be indexed here. I don't know, @Skrypt perhaps you have a hint?

Piedone avatar May 07 '24 19:05 Piedone

It is probably the same issues as with multiple taxonomy terms.

Skrypt avatar May 08 '24 00:05 Skrypt

I have noticed the same issue with multiple taxonomy terms.

MEllis-Bethany avatar May 08 '24 12:05 MEllis-Bethany

Multiple taxonomy terms work fine with this format. ,{ "terms": { "Article.Category.Inherited": [{% for tax in taxonomy %}"{{tax}}"{% unless forloop.last %},{% endunless %}{% endfor %}] } }

PBMikeW avatar Sep 26 '24 23:09 PBMikeW