altralaser
altralaser

Reputation: 2073

Different relevance of fields in elasticsearch query

I have about 10 fields in my elastic index. I want to search over all these fields. So I set no fields parameter in my query:

GET /_search
{
    "query": {
        "query_string": {
            "query": "this OR that"
        }
    }
}

Now I want to set the field "title" more relevant. I know that I can do this by:

"fields": ["title^5"]

My problem is that in this case I only search over the field "title", isn't it?
is there a possibility to search over all fields but set one of these fields more relevant?

Upvotes: 0

Views: 156

Answers (1)

Val
Val

Reputation: 217254

What I suggest is to specify all the 10 fields you want to search on so you can boost specific ones, like this:

GET /_search
{
    "query": {
        "query_string": {
            "query": "this OR that",
            "fields": ["title^5", "field2", "field3", ...]
        }
    }
}

Upvotes: 1

Related Questions