Hello! I'm using query_string to perform search on my index and retrieve the documents that have a partial match of the search term.
So, before I introduce my question, I'll tell a little about the search environment. I have an index called Jobs and each document has a field called role. So, for the purpose of this question, I can say that I have 4 documents inserted and each one has the following roles: "Developer", "iOS Developer", "Android Developer", "Developer DevOps".
When I search for "dev", what I want it's something like this on the response: ["Developer", "Developer DevOps", "iOS Developer", "Android Developer"].
But what I get from the response it's not in the "sorted" form I was looking for: ["iOS Developer", "Developer", "Android Developer", "Developer DevOps"].
This is my search code:
GET jobs/doc/_search
{
"query": {
"query_string" : {
"query" : "role: dev*"
}
}
}
So to summarize, I want based on the search term, retrieve the roles ordered first by the ones that start with it and the remaining strings that has the search term in the middle. I've also tried RegExp and filter, but none of them helped me with this issue.
If someone could help pointing me the best way to achieve this kind of thing, I'd very thankful.
Thanks!