Search code examples
elasticsearchfoselasticabundle

Unknown key for a VALUE_STRING in [index]


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.


Solution

  • Just I fixed my $params array this way :

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