Chance
Chance

Reputation: 11315

In Elastic Search 7, is it possible to have a Context Suggester that boosts rather than filters?

The Context Suggester documentation states:

The completion suggester considers all documents in the index, but it is often desirable to serve suggestions filtered and/or boosted by some criteria. [emphasis mine]

But I don't see how to prevent the context from actually filtering. The only way the or statement seems applicable is in a scenario where there are multiple contexts provided.

Is there a way to use a single context to boost rather than filter?

Thanks!

Upvotes: 1

Views: 859

Answers (1)

Gibbs
Gibbs

Reputation: 22974

Yes, it's really confusing.

As you read the documentation, there is one main difference with context suggester is that it avoids entire Inded scan. Hence context is mandatory parameter in the suggester query.

Is there a way to use a single context to boost rather than filter?

No. As a boost alone, there is no way.

To achieve what is needed is one way, kind of hack. As you know the list of contexts already, you need to provide all the contexts in the context query with different boosts. Then it is kind of boosting all the contexts.

POST place/_search?pretty
{
    "suggest": {
        "place_suggestion" : {
            "prefix" : "tim",
            "completion" : {
                "field" : "suggest",
                "size": 10,
                "contexts": {
                    "place_type": [ 
                        { "context" : "cafe", boost:1},
                        { "context" : "restaurants", "boost": 2 }
                     ]
                }
            }
        }
    }
}

Here, I set boost for both the contexts. Then it includes all contexts and lists by boost.

Again, if a term is present in many contexts, then the context with maximum score gets the priority.

Note: Examples are from the documentation.

Upvotes: 1

Related Questions