2
votes

I'm trying to use ElasticSearch to find all records containing a particular string. I'm using a match query for this, and it's working fine.

Now, I'm trying to sort the results based on a particular field. When I try this, I get some very unexpected output, and none of the records even contain my initial search query.

My request is structured as follows:

{
"query": 
{
    "match": {"_all": "some_search_string"}
 },
 "sort": [
 {
    "some_field": {
        "order": "asc"
        }
 }
 ] }

Am I doing something wrong here?

1
did you get solution?c.jack

1 Answers

1
votes

In order to sort on a string field, your mapping must contain a non-analyzed version of this field. Here's a simple blog post I found that describes how you can do this using the multi_field mapping type.