Boosting a non queried field


(Ariella ) #1

I want to run a query string query, meaning to query the "_all" field, but I would like to score higher a document in which the term I searched for was in a specific field.
For example, i want to search the term "john" over a "person" type (using a query string query because I want everything that's connected to john somehow), but if john appears in the field "name", I want to score it higher than a document in which "john" appears in the field "street".

How can I do that?
Thanks


(Xavier Facq) #2

You can look at the Bool Query : https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

You can add your must() with John on _all field and a should() on the field name = John. So that documents with John in the name will have a best score.


(Ariella ) #3

yeah i thought of that way, i was just wondering if there is another way without adding queries to each boosted field separately.
thanks anyway!


(system) #4

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