In elastic, I want to count a list of terms in text, but discount any terms that are being counted as a subset part of other terms of interest. I would like to count a list of phrases in the text, but without double counting subset terms if they sit in the other phrases. For example:
"text": "We care a great deal about data collection. Data is at the forefront of what we do. It is very important to monitor different datasets."
Phrases of to count: "data", "data collection", "datasets"
I would like to have an Elastic query that returns the matches, excluding overlapping terms, like:
I think at the moment, as "data" can be found in "data collection" and "datasets" as well as "data", you would get:
which would overstate "data" as a term by itself, given that it is already counted in "Data collection" and "datasets".
Thank you in advance.
Daniel

