感谢您之前提供的帮助,因此现在我可以进一步了解 Elasticsearch 。
到目前为止,我可以使用elasticsearch操纵数据。我在我的php框架(codeigniter)中创建了新库。
输入多个数据后。
由于 flex 的最佳部分是搜索(是的,当然。。。),我想知道搜索功能。
但是当我创建它时,我对结果感到失望。
与kibana不同,我的结果没有显示我之前输入的关键字的突出显示文本。
问题是:
如何在 Elasticsearch 结果中突出显示文本
我读了这篇文章:
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-request-highlighting.html
但我不知道将这段代码放在哪里:
{
"query" : {...},
"highlight" : {
"fields" : {
**"content" : {}**
}
}
}
由于我在php中的代码仅如下所示:
Controller :
$product = $this->elasticsearch->searchDocsWithParameter($type, $post);
$result = json_decode(json_encode($product),true);
echo "total took:";
echo $result['took'];
$x=0; $no=1;
while($x <= $result['_shards']['total']):
echo $no; echo" . ";
echo $result["hits"]["hits"][$x]['_source']['en_question'];
echo"<br>";
echo $result["hits"]["hits"][$x]['_source']['en_answer'];
echo"<br><br>";
$x++; $no++;
endwhile;
图书馆 :
public function searchDocsWithParameter($type, $query")
{
return $this->call($type . '/_search?' . http_build_query(array('q' => $q)));
}
我已经在搜索它,没有人发布它。
那就是为什么我问这个论坛。请帮助我。
非常感谢
谢谢
最佳答案
也许这可以帮助您了解其工作原理:
Different result when using GET/POST in elastic search
但是对我来说,更好的选择应该是从composer下载elasticsearch库并在您的项目中使用它:
https://philsturgeon.uk/php/2012/05/07/composer-with-codeigniter/
那么您将拥有一个更广泛的使用库:
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
关于codeigniter - 如何在 Elasticsearch 结果中突出显示文本-Codeigniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38114595/