Using fos_elastica.finder.post_index.post
service to get list of available sugesstion post as defined under my mapping configuration:
fos_elastica:
clients:
default: { host: elasticsearch, port: 9200 }
indexes:
post_index:
client: default
index_name: post_index
types:
post:
properties:
suggest:
type: completion
id:
type: keyword
title:
type: keyword
description:
type: keyword
persistence:
driver: orm
model: App\Entity\Post
finder: ~
provider: ~
listener: ~
This is my php code under SearchController:
$finder = $this->container->get('fos_elastica.finder.post_index.post');
$compelation = [
"suggest" => [
"suggest" => [
"text" => "test",
"completion" => [
"field" => "suggest",
"fuzzy" => ["fuzziness" => 2]
],
]
]
];
$result = $finder->find($compelation);
The post request work great under kibana console and return the expected result:
POST post_index/_search?pretty
{
"suggest": {
"anything-suggest" : {
"text" : "test",
"completion" : {
"field" : "suggest",
"fuzzy" : {
"fuzziness" : 2
}
}
}
}
}
This is the error I'm getting:
suggestion does not support [field]