How can we combine Query DSL and Query time boosting to control relevance

I want to boost the relevance of one type of documents over another. The way to differentiate between the documents is on the basis of a field value say "type" which can be "a" or "b".

For type "a" I want to use different query time boost values than for type "b".

Is there a way to achieve this?

One way could be to use my custom script for scoring but I am avoiding that path if this can be directly achieved by elastic search for performance and maintenance overheads.

Thanks

Hey,

you can configure boosting based on the _type field. So you would need to use a filter query on the _type field as part of a should clause.

Hope that makes sense.

--Alex

I guess my use of the word type was misleading. Actually they are both same _type as far as Elastic Search is concerned. The type for me is my own field in the document lets say category a and category b.

Now I want to configure boosting on same field with different value for different category of documents.

Say I want to give boost of 2 to name in case of document category = a and boost 1 for document in category b.

I saw this but I am not sure if I can use something similar.. I need to boost multiple fields differently on basis of some field value in the document.

Check out the examples in the definitive guide - there is one examples with two should clauses based on the content.. instead of a match query you may just need a term one

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.