Skip to content

Querying by multiple form fields filter #34

@florentsorel

Description

@florentsorel

Hi,

I'm new with Elastic. I would like to search by multiple form fields.

For example I have my form with: company_name, contacts.first_last_name.

In my Elastic structure I have company_name, contacts.firstname, contacts.lastname

I want search by name (concat firstname and lastname) but if I filled the company_name form field I want to search company_name AND firstname + lastname

I think it's working with concat field, but who to add other field ?

$clients = Client::searchByQuery([
    'multi_match' => [
        'query' => $request->get('first_last_name'),
        "type" => "cross_fields",
        'operator' => 'and',
        'fields' => [
            'contacts.firstname',
            'contacts.lastname',
        ]

    ]
]);

Btw, how to add some checkboxes to the query with Elasticquent ? Of course, firstname, lastname and company_name will be included in the query too. I think it's a complex filter :/

Thx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions