我正在尝试使用FOSElastica Bundle通过全局索引搜索返回亮点。
我的配置中有一个全局索引查找器(yml 文件):
fos_elastica:
clients:
default: { host: %elastic_host%, port: %elastic_port% }
indexes:
myIndex:
client: default
finder: ~
types:
# different types here
我按照文档(这里)使用它:
$finder = $this->container->get('fos_elastica.finder.myIndex');
// Returns a mixed array of any objects mapped
$results = $finder->find('whatever');
这完美地工作并返回预期的结果。现在我想使用例如ES的快速矢量荧光笔来突出显示结果中的单词。但是我没有找到任何示例或任何文档来这样做。
我想我需要定义一个更合适的 \Query 对象,例如:
$query = new \Elastica\Query();
$query->setHighlights(array("whatever"));
$query->setTerm("whatever");
$results = $finder->find($query);
但我找不到任何信息。有什么提示吗?
非常感谢 !!