Elasticsearch sort based on the number of occurrences a string appears in an array
问题 I have an array field containig a list of strings: ie.: ["NY", "CA"] At search time I have a filter which matches any of the strings in the array. I would like to sort the results based on documents that have the most number of appearances of the searched string: "NY" Results should include: document 1: ["CA", "NY", "NY"] document 2: ["NY", FL"] document 3: ["NY", CA", "NY", "NY"] Results should be ordered as such User 3, User 1, User 2 Is this possible? If so, how? 回答1: For those curious, I