Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (19.9k points)

I have stored sentences in elasticsearch for autosuggestion.

format:

{

  "text": "what is temperature in chicago"

}

it suggests correctly when w or wha or what typed. but I am wondering if there is any way I can fetch most search sentences from elasticsearch.

1 Answer

0 votes
by (25.1k points)

Your request body should look something like this:

        {

            "query": {

                //your query

            },

            "aggs": {

                "common" : {

                    "terms" : { "field" : "text.keyword", "size": 20 }

                }

            }

        }

Related questions

Browse Categories

...