Hello all, nooby here. I'm trying to write a search query but I'm having some problems.
I have an index called Categories. It has the following fields: title, tags (which is just a big string with keywords) and total, a number which represents the total number of items I have for this category.
Given search query T, I want to fetch 10 results where title/tags are T, or begin with T, or contain T. I want to sort them based on score, and then based on total. I also want to disable term frequency consideration into the score. That's the gist of it.
{
"index": "categories",
"body": {
"size": 10,
"query": {
"bool": {
"minimum_should_match": 1,
"should": [
{
"query_string": {
"default_field": "_all",
"query": "T"
}
},
{
"query_string": {
"default_field": "_all",
"query": "T*"
}
},
{
"query_string": {
"default_field": "_all",
"query": "*T*"
}
}
],
"must": [
{
"range": {
"total": {
"gt": 0
}
}
}
]
}
},
"sort": {
"_score": {
"order": "desc"
},
"total": {
"order": "desc"
}
}
}
}
This query works, however I'm unable to impose the no-term frequency rule. I've tried writing constant_score to encapsulate each of those query_strings or the bool, but I only got exceptions.
Any ideas? Also, just making sure but am I writing my query correctly, or should I write it in a different fashion? Thanks