Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about boosted fields in Multi Match Query #21

Closed
tortuetorche opened this issue Jan 24, 2016 · 4 comments
Closed

Question about boosted fields in Multi Match Query #21

tortuetorche opened this issue Jan 24, 2016 · 4 comments

Comments

@tortuetorche
Copy link

Hi,

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: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#CO115-1

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

$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.

See adamfairholm/Elasticquent#25 for the original issue and iverberk/larasearch#73 for a similar feature request on another Laravel Elastic Search package.

Cheers,
Tortue Torche

@timgws
Copy link
Member

timgws commented Jan 25, 2016

Did you try complexSearch? This should do exactly as you have described. If it does not, please let me know.

    $books = Book::complexSearch([
        'body' => [
            'multi_match' => [
                'query' => 'Moby Dick',
                'fields' => ['title^3', 'author']
            ]
        ]
    ]);

@timgws
Copy link
Member

timgws commented Jan 25, 2016

Also, you could use searchByQuery if you do not need extra parameters...

    $books = Book::searchByQuery([
        'multi_match' => [
            'query' => 'Moby Dick',
            'fields' => ['title^3', 'author']
        ]
    ]);

Here (https://github.com/elasticquent/Elasticquent#query-based-search) is the documentation!

@timgws
Copy link
Member

timgws commented Jan 28, 2016

@tortuetorche ... did this answer your question?

@tortuetorche
Copy link
Author

Yes, you did 👌
Your package will be very useful for my future projects! 😎

Many thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants