Elasticquent icon indicating copy to clipboard operation
Elasticquent copied to clipboard

Question about boosted fields in Multi Match Query

Open tortuetorche opened this issue 9 years ago • 1 comments

Hi Adam,

Is it possible to apply boost on Individual fields with the caret (^) notation? Like this sample:

{
  "multi_match" : {
    "query" : "this is a test",
    "fields" : [ "subject^3", "message" ] 
  }
}

Source: http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#CO47-1

If it's possible, how to do this with your package? Something like this?

$client = new \Elasticsearch\Client();

$params = [
    'index' => 'default',
    'type'  => 'books'
    'body' => [
        'multi_match' => [
            'query' => 'Moby Dick',
            'fields' => ['title^3', 'author']
        ]
    ]
];

$collection = new \Elasticquent\ElasticquentResultCollection($client->search($params), new Book);

The title field is three times as important as the author field.

Cheers, Tortue Torche

tortuetorche avatar Mar 31 '15 11:03 tortuetorche

See https://github.com/iverberk/larasearch/issues/73 for a similar feature request on another Laravel Elastic Search package.

tortuetorche avatar Apr 02 '15 07:04 tortuetorche