Elastic sorting of search documents, indexing

I have 9000 documents in my ElasticSearch index.

I want to sort by the parsed string field, so in order to do this I knew (via Google) that I had to update the collation to make the field unparsed, so I can sort by that field and I have to re-index the data again. to reflect the change in display.

The reindexing process consumed about 20 minutes on my machine.

The weird thing is that the reindexing process took about 2 hours on a very powerful production server.

I checked the memory status and CPU usage on this server and everything was fine.

What I want to know:

  • Is there a way to sort documents by a parsed, tokenized field without re-indexing all documents?

  • If I have to re-index all documents, why does it take such a long time to re-index the documents on the server? or how to trace the reasons for slowness on this server?

+3


source to share


1 answer


As long as the field is stored in the _source, I'm sure you can use a script to create custom fields on every search.

{
  "query" : { "query_string" : {"query" : "*:*"} },
  "sort" : {
    "_script" : { 
        "script" : "<some sorting field>",
        "type" : "number",
        "params" : {},
        "order" : "asc"
    }
  }
}

      



This has the disadvantage of re-evaluating the server side script sorting on every search, but I solve (1).

0


source







All Articles