1
votes

I am trying to boost certain indices in my elastic search query. Right now, my query is looking like this.

var query = {
    "query": {
        "query_string": {
            "fields": ["FirstName", "LastName"],
            "query": "Hank Hill",
            "default_operator": "AND"
        }
    }
};

var boosted_indices = {
    "index_A" : 1.0,
    "index_B" : 1.0,
    "index_C" : 10.0
};

if (boosted_indices) {
    query["indices_boost"] = boosted_indices;
}

// stringify and send query in an http.get request

I know that my query without boosting any indices works as I expect. However, I am still getting a lot of results from "index_A" in my query results, rather than the heavily boosted index_C. I know that there should be a similar number of matching results in A and C, so the issue must be that I am not boosting the query correctly.

Did I set up my query JSON incorrectly? On the tutorial I linked, it did not give much context.

One other thing I noticed.. the "_score" field for the returned documents... all of them are set to null. Might this have something to do with my documents not being boosted according to the index they came from?

1
according to the comment in code looks like you are using get request. Could you try post request ?keety

1 Answers

1
votes

I hope you are not using the sort parameter in query. This could be the reason that _score is null and you are not getting expected results.

Does this help?