user4455372
user4455372

Reputation:

PHP elasticsearch partial match

i want to search with elasticsearch and show out the result with php. i want to make partial match like it's in mysql for ex:

select * from table_name where title like '%abc%'

But my codes doesn`t work:

$params = [
    'index' => 'my_index',
    'type' => 'my_type',
    'body' => [
        'query' => [
            'match' => [
                'title' => '.*abc.*'
            ]
        ]
    ]
];

Upvotes: 1

Views: 563

Answers (1)

user4455372
user4455372

Reputation:

I was using 'match' instead of 'regex'

$params = [
    'index' => 'my_index',
    'type' => 'my_type',
    'body' => [
        'query' => [
            'regexp' => [
                'title' => '.*abc.*'
            ]
        ]
    ]
];

Upvotes: 3

Related Questions