# Query boost issues

**URL:** <https://discuss.elastic.co/t/query-boost-issues/136704>\
**Category:** Elasticsearch\
**Created:** [June 20, 2018, 1:38pm UTC](https://discuss.elastic.co/t/query-boost-issues/136704 "2018-06-20T13:38:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Realz](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@Realz](https://discuss.elastic.co/u/Realz)\
**Post date:** [June 20, 2018, 1:38pm UTC](https://discuss.elastic.co/t/query-boost-issues/136704/1 "2018-06-20T13:38:54Z")

</div>

Hello,  
i have some issues with query boosting, here is my search request in PHP:

```
        $params = [
        'index' => 'formations',
        'type' => 'all',
        "from" => 0, "size" => 40,
        "body" => [
            "query" => [
                "bool" => [
                    "should" => [
                        "multi_match" => [
                            "fields" => ["name^150", "cities^110"],
                            "query" => $request->research
                        ]
                    ]
                ]
            ],
            "highlight" =>[
                "pre_tags" => ['<strong class="text-primary">'],
                "post_tags" => ['</strong>'],
                'fields' => [
                    'villes' => new \stdClass(),
                ],
            ]
        ]
        ];

```

When i apply a boost of 150 on the name field, its all working fine, guessing im typing 'bartender' in research bar. If i add a city to the research like 'bartender chicago' , all results containing the word bartender will come first ,I want that if the search contains the 2 keywords it will come first in the results.  
But if i apply a boost \> 150 on the city, if i type any name and Chicago, it will always show results with chicago first

Can someone explain me how i can do that ?  
Here an example of the data i push :  
$data = [  
'body' =\> [  
'id' =\> 1,  
'intitule' =\> "bartender",  
'cities' =\> ['chicago', 'new York'],  
'index' =\> "formations",  
'type' =\> 'all',  
'id' =\> 1,  
];  
$data = [  
'body' =\> [  
'id' =\> 2,  
'intitule' =\> "bartender",  
'cities' =\> ['new York'],  
'index' =\> "formations",  
'type' =\> 'all',  
'id' =\> 2,  
];

Thanks a lot,  
sorry for my english

---

<div class="post-metadata">

**Author:** ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)\
**Post date:** [June 20, 2018, 3:55pm UTC](https://discuss.elastic.co/t/query-boost-issues/136704/2 "2018-06-20T15:55:35Z")

</div>

I think the right approach is not to boost on each fields individually, but add a new multi\_match clause of type `cross_fields`.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields)

```
        "query" => [
            "bool" => [
                "should" => [
                    "multi_match" => [
                        "fields" => ["name", "cities"],
                        "query" => $request->research
                    ],
                    "multi_match" => [
                        "type" => "cross_fields",
                        "fields" => ["name", "cities"],
                        "query" => $request->research,
                        "operator": "AND",
                        "boost" => 3
                    ]
                ]
            ]
        ]
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 18, 2018, 3:55pm UTC](https://discuss.elastic.co/t/query-boost-issues/136704/3 "2018-07-18T15:55:44Z")

</div>

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