How to sort my data in elasticsearch

how to sort by asc in logstash?
i want new add field,it's self increment column,and insert dest index,how make it?

Hi @lz840408,

Are you ingesting your data using Logstash into Elasticsearch or another target? Is there any reason you don't want to apply the sorting at query stage rather than ingestion?

if input is elasticsearch,how to sort in input?

Can you please give a bit more information on what you're trying to do? What are the inputs and outputs to your Logstash pipeline?

If I understood correctly, you want to sort data as is comes.
Badger already responded
Another option is to use ID from input or generate by your as autoincrement and use that for doc_id in output. Always you can use Ruby code for tweaking.

If this not helped, as Carly said, pls provide more information.

you are right,i want test increnment sync data between es,so i want build a new column as incr sequence attribute.
do you have ruby code or sample?
because i trying some metod,but not effect

i found an "action" parameter in output of elasticsearch plugins,it's had four option index,delete,create,update,i notice update and delete option,it means opertion by id column,this id column is elasticsearch default _id column?
if my index is not assign id obvious,it's random generate, what can i do?

For Ruby code samples as per one of @Rios's suggestion, I would recommend having a look at the examples in the documentation, particularly those for creating a new field.

If you don't have an id attribute in your documents already that makes sense, you could also have a look at the UUID plugin as well. There are many ways to generate an ID.

1 Like

Have you solved this?
Can be messy with autoincrementing, because after every exit process you have to get max(id) from ES.

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