Top N records

(Rashmi Nagpal) #1

Hi there,

Can someone guide me how to extract top five records from elasticsearch,I've used size query as well, but it returns all the documents.
Goal is to get data in json format after sorting on basis of store size which is one of keys in that json and extract only five such jsons.
Below is my search query: [ip-address]/_cat/indices?format=json&s=store.size:desc
I'm newbie in this, many apologies if this seems to be a silly question.

Also, if someone provide me hints then it is too, okay!

Thanks a bunch, in advance!!

(David Pilato) #2
GET _search?size=5

(Rashmi Nagpal) #3

Thank a real bunch sir for your prompt reply!
Perhaps, I'm looking for a query in culmination with "cat" command since, data which is stored is an array of multiple jsons something like,
[{json1},{json2},{json3}.... and 10,000 more] but I want to retrieve top 5 such json strings from that array.

(David Pilato) #4

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

(system) closed #5

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