How to expand query_string

Hello !

i want to expand query for more revelance.

For exemple, i want to perform this query "aa AND bb AND cc" on multiple fields, but i want to boost the revelance of one field -> title

i want to do something like this :

'query' => [
    'query_string' => [
        'fields' => [
            'title',
            'field1',
            'field2',
            'field3',
            'field4',
            'field5',
        ],
        'query' => 'title:(aa AND bb AND cc)^5 OR
            (title:(aa AND bb)^3 OR cc) OR 
            (title:(aa AND cc)^3 OR bb) OR 
            (title:(bb AND cc)^3 OR aa) '

This way, my doc with a title containing "aa" and "bb" and "cc" will be on top, then the doc with only 2 of them will follow.

I want to know if there a way to acheive this with Es without to do it manually.

Thanks !!

I suggest reading this chapter: https://www.elastic.co/guide/en/elasticsearch/guide/current/multi-field-search.html

Likely a multi_match query, boosting your title field, would work?

Mike McCandless

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