babenkoivan / elastic-scout-driver-plus

Extension for Elastic Scout Driver
MIT License
267 stars 52 forks source link

How to write more_like_this #133

Closed muzidudu closed 2 years ago

muzidudu commented 2 years ago

How do you implement this code GET /_search { "query": { "more_like_this" : { "fields" : ["title", "description"], "like" : "Once upon a time", "min_term_freq" : 1, "max_query_terms" : 12 } } }

babenkoivan commented 2 years ago

Hey @muzidudu, there is currently no builder for more_like_this query, but you can use a raw query:

$query = [
    'more_like_this' => [
        'fields' => ['title', 'description'],
        'like' => 'Once upon a time',
        'min_term_freq' => 1,
        'max_query_terms' => 12
    ]
];

$searchResult = Book::searchQuery($query)->execute();
muzidudu commented 2 years ago

thx for reply !
I know how to do it.