如何在fos elasticsearch中使用其他类型的搜索

How to use other types of searching in fos elasticsearch

我使用symfony 4 + fos elasticsearch。 此代码对我有用:

$finder = $finder->getRepository(\App\Entity\User::class)->find($searchTerm);

哪个卷曲是

curl -XGET 'http://localhost:9200/app/user/_search' -d '{"query":{"match_all":{}}}'

curl -XGET 'http://localhost:9200/app/user/_search' -d '{"query":{"query_string":{"query":"a"}}}'

我想用match-query-phrase-prefixhttps://www.elastic.co/guide/[...]dsl-match-query-phrase-prefix

fos怎么办?文档非常小。 请帮忙。

FOS Elasticsearch 在后台使用 Elasticsearch 客户端 Elastica。使用 FOS Elasticsearch 创建的 "finder" 服务来 运行 对您的索引进行自定义 Elastica 查询:

$finder = $this->container->get('fos_elastica.finder.app.user');

$matchQuery = new \Elastica\Query\MatchPhrasePrefix();
$matchQuery->setFieldQuery('name', 'a');

$data = $finder->find($matchQuery);