Query Elasticsearch to get count of Keywords within matched Keywords

Data:

Doc 1:
       field_a : ["A", "B", 'C", "D", "E"]

Doc 2:
       field_a : ["A", "D", "G", "Z", "Y"]

Doc 3:
       field_a : ["F", "W", 'C"]

Doc 4:
       field_a : ["A", "B", 'C", "D", "E", "Z", "Y"]

Doc 5:
       field_a : ["A", "B", "C"]

PS: field_a is of Keyword type.

Query:

terms: ["A", "B", "C", "D", "E"]

Required Response:

Doc 1: 5
Doc 2: 2
Doc 3: 1
Doc 4: 5
Doc 5: 3

Require the required response. It will be perfect if there is any way to generate Custom Score Function to get the same.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.