Get count of analyzed strings as a result back within list of fields

Hi! I could use help with this query.

GET index_*/_search?size=20
{
"size": 0,
"_source": ["sentimentScore","category", "contentAnalyzed"],
"query": {
"bool": {
"must": [
{ "match_phrase_prefix": {"contentAnalyzed": "x" }},
{ "match": {"language": "en" }}
]
}
}
}

Returning results like this:

{
"_index": "x",
"_type": "x",
"_id": "x",
"_score": 6.3490815,
"_source": {
"sentimentScore": 0.6034262,
"contentAnalyzed": "string of text",
"category": "category"
}
}

How do I get a count of documents with the exact string in the contentAnalyzed field (which is analyzed) back in the result set?

Thanks,
Casie

Hi,

for exact phrase matches you need to use the match_phrase query. If you run this on an analyzed field (which I guess contentAnalyzed is, judging from its name) you might still get matches that are not "exact" string matches (depending on what you mean by "exact"), e.g. mit different lowecasing etc...

If you need really "exact" (as in same case, full field, no stemming etc...) matches, you need another field that is not analyzed. Elasticsearch 5.0 has the keyword datatype for that.

The total document count matching a query should be part of the response, what are you missing there?

Thanks!

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