# Analysis of search query VS hits? Identifying the missing terms?

**URL:** <https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468>\
**Category:** Elasticsearch\
**Created:** [May 3, 2017, 10:07pm UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468 "2017-05-03T22:07:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will5639](https://avatars.discourse-cdn.com/v4/letter/w/cc9497/32.png) [@Will5639](https://discuss.elastic.co/u/Will5639)\
**Post date:** [May 3, 2017, 10:07pm UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468/1 "2017-05-03T22:07:29Z")

</div>

I've got a match query I allow for a minimum match of "1\<-1 6\<-2" so the user can search for say: "dark souls 3" they'll get document results for "dark souls" or "dark souls 2". Is there any way via the ES response that I can capture what terms did not match? e.g. a hit of "dark souls" could express that "3" was not found?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 4, 2017, 7:22am UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468/2 "2017-05-04T07:22:15Z")

</div>

Check out named queries  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-named-queries-and-filters.html)

---

<div class="post-metadata">

**Author:** ![Will5639](https://avatars.discourse-cdn.com/v4/letter/w/cc9497/32.png) [@Will5639](https://discuss.elastic.co/u/Will5639)\
**Post date:** [May 4, 2017, 6:47pm UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468/3 "2017-05-04T18:47:01Z")

</div>

What I'm seeing that do is just tell me the name of the root boolean query (which is always present). I'm looking more for a breakdown of the analyzed search terms.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 4, 2017, 8:05pm UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468/4 "2017-05-04T20:05:10Z")

</div>

So you'll need to tokenize the query string in your client (you can use the \_analyze api to do this) and formulate a bool query with named child clauses containing these tokens.  
Ugly but the only way I can see of doing this.

---

<div class="post-metadata">

**Author:** ![Will5639](https://avatars.discourse-cdn.com/v4/letter/w/cc9497/32.png) [@Will5639](https://discuss.elastic.co/u/Will5639)\
**Post date:** [May 4, 2017, 9:21pm UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468/5 "2017-05-04T21:21:07Z")

</div>

I see! It does get ugly but I think my particular environment works. (I already was doing an \_analyze as I needed a token count from the search string).

Interesting trivia (didn't hold me up) that I learned while implementing: In a Nested query, the child clauses albeit named were not returned.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 1, 2017, 9:29pm UTC](https://discuss.elastic.co/t/analysis-of-search-query-vs-hits-identifying-the-missing-terms/84468/6 "2017-06-01T21:29:33Z")

</div>

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