Unknown key for a VALUE_STRING in [index]

famas23 picture famas23 · Oct 10, 2018 · Viewed 7.7k times · Source

I'm trying to find a way where I can build my $params array using the native syntax to search for a post which name is equal to 'test':

$params = [
    "index" => "post_index",
    "type" => "post",
    'body' => [
        'query' => [
            'match' => [
                'name' => 'test'
            ]
        ]
    ]
];
$result = $finder->find($params);

Unfortunately I'm getting this error:

Unknown key for a VALUE_STRING in [index].

I know that I can use some Elastic\Query\Match to build my query.

Answer

famas23 picture famas23 · Oct 10, 2018

Just I fixed my $params array this way :

$q = [
    'query' => [
        'match' => [
            'title' => 'test'
        ]
    ]
];