1

I am new to ElasticSearch and I am trying to query on multiple fields of a a nested document. It actually succeeds only when there is an exact match.

return Record::search()
            ->multiMatch([
                'original_name',
                'some_id',
                'contributors.name',
                'customNames.custom_name',
            ], ' * '.$searchTerm.' * ', ['fuzziness' => 'AUTO'])
            ->size(500)->get()->hits();

Any ideas?

SQL equivalent would be:

SELECT * FROM WHERE records LIKE '%'.$seachTerm.'%' (plus some extra joins)

1 Answer 1

1
 $query = [
            'multi_match' => [
                'query' => $searchTerm,
               'fields' => [
                    'original_name',
                    'some_id'
                ]
             ],
          ];

$records = Record::searchByQuery($query, '', '', $count, $offset, [
                'id' => ['order' => 'desc']
            ]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.