# Elasticsearch query for Query Suggestions

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [March 17, 2023, 9:57pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976 "2023-03-17T21:57:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [March 17, 2023, 9:57pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/1 "2023-03-17T21:57:16Z")

</div>

Does anyone have an example query of what Query Suggestions actually uses for Elasticsearch? According to ([Query Suggestions Guide | Elastic App Search Documentation [8.6] | Elastic](https://www.elastic.co/guide/en/app-search/current/query-suggestions-guide.html)),

" Query suggestions use the `best_fields` type."  
and  
" A query suggestion will **match deeper** on a single field and apply **less search logic** when compared to a search query."

I would like to see an example so I can make my own with some adjustments.

---

<div class="post-metadata">

**Author:** ![Sean\_Story](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sean_story/32/69987_2.png) [@Sean\_Story](https://discuss.elastic.co/u/Sean_Story)\
**Post date:** [March 27, 2023, 1:35pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/2 "2023-03-27T13:35:56Z")

</div>

Hi @ryans

If you want to see exactly what requests Enterprise Search is sending to Elasticsearch, you can add the `X-Enterprise-Search-Debug` header to your Enterprise Search API request. So if you were using cURL, it would look like:

```auto
-H 'X-Enterprise-Search-Debug: true

```

See: [https://www.elastic.co/guide/en/app-search/current/troubleshooting.html#troubleshooting-debugging-queries-debug-header](https://www.elastic.co/guide/en/app-search/current/troubleshooting.html#troubleshooting-debugging-queries-debug-header)

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [March 27, 2023, 2:57pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/3 "2023-03-27T14:57:47Z")

</div>

Thanks Sean, but it doesn't seem to work for Query Suggestions. I got no additional data:

curl -X POST '\<ENTERPRISE\_SEARCH\_BASE\_URL\>/api/as/v1/engines/parks-data/query\_suggestion'   
-H 'Content-Type: application/json'   
-H 'Authorization: Bearer API\_KEY'   
-H 'X-Enterprise-Search-Debug: true'   
-d '{  
"query": "car",  
"types": {  
"documents": {  
"fields": [  
"title",  
"states"  
]  
}  
},  
"size": 3  
}'

Is this a bug?

---

<div class="post-metadata">

**Author:** ![Sean\_Story](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sean_story/32/69987_2.png) [@Sean\_Story](https://discuss.elastic.co/u/Sean_Story)\
**Post date:** [March 27, 2023, 4:49pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/4 "2023-03-27T16:49:51Z")

</div>

@ryans you need to look in the Enterprise Search logs to see all of the Elasticsearch requests that are generated from this Enterprise Search request. They are not included in the request response body.

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [March 27, 2023, 5:18pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/5 "2023-03-27T17:18:02Z")

</div>

Thanks Sean. I checked the logs and still didn't see any additional information:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/e/ee722f432cb750be9343b173688d34e433f0c3bf.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/1/91d64352224114d3c3819059ef8199a8ff265223.png)

Is there some setting I need to enable or something?

---

<div class="post-metadata">

**Author:** ![Sean\_Story](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sean_story/32/69987_2.png) [@Sean\_Story](https://discuss.elastic.co/u/Sean_Story)\
**Post date:** [March 27, 2023, 6:25pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/6 "2023-03-27T18:25:08Z")

</div>

Hi @ryans ,

Sorry, I did not clarify. I'm talking about the application server logs (system logs), not the API Event Logs.

If you deployed with Elastic Cloud, you can access these logs by enabling logging and metrics, or by reaching out to support. If you have deployed Enterprise Search on infrastructure you own, you can find the logs at the `<install-root>/enterprise-search.*/logs/app-server.log`

---

<div class="post-metadata">

**Author:** ![ryans](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@ryans](https://discuss.elastic.co/u/ryans)\
**Post date:** [March 28, 2023, 1:57pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/7 "2023-03-28T13:57:18Z")

</div>

Sean,

Thanks so much! I was able to figure out the logging and find the query. Much appreciated.

---

<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:** [April 25, 2023, 1:57pm UTC](https://discuss.elastic.co/t/elasticsearch-query-for-query-suggestions/327976/8 "2023-04-25T13:57:48Z")

</div>

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