elasticsearch-哪位朋友知道es-php或mmanos/laravel-search的查询结果高亮问题
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了elasticsearch-哪位朋友知道es-php或mmanos/laravel-search的查询结果高亮问题,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2806字,纯文字阅读大概需要5分钟。
内容图文
![elasticsearch-哪位朋友知道es-php或mmanos/laravel-search的查询结果高亮问题](/upload/InfoBanner/zyjiaocheng/155/a8b2cde3ba0b4454b9ddd333636ac46c.jpg)
不乱以上哪种方式,哪位朋友能指点一二,感谢!!!
$params=[
'index' => 'n_index',
'type' => 'n_type',
'body' => [
'query' => [
'match' => ['ntitle' => '要查询的词']
],
'highlight'=>[
'pre_tags'=>['', ''],
'post_tags'=>[' ', ''],
'fields'=>[
'ntitle'=>[]
]
]
]
];
$response = $this->client->search($params);
echo "";
var_dump($response);
echo "
";
以上代码可以查出以下结果
array(4) {
["took"]=>
int(6)
["timed_out"]=>
bool(false)
["_shards"]=>
array(3) {
["total"]=>
int(5)
["successful"]=>
int(5)
["failed"]=>
int(0)
}
["hits"]=>
array(3) {
["total"]=>
int(3)
["max_score"]=>
float(1.8223838)
["hits"]=>
array(3) {
[0]=>
array(5) {
["_index"]=>
string(7) "n_index"
["_type"]=>
string(6) "n_type"
["_id"]=>
string(1) "6"
["_score"]=>
float(1.8223838)
["_source"]=>
array(1) {
["ntitle"]=>
string(35) "ntitle内容2"
}
}
[1]=>
array(5) {
["_index"]=>
string(7) "n_index"
["_type"]=>
string(6) "n_type"
["_id"]=>
string(1) "7"
["_score"]=>
float(1.2087858)
["_source"]=>
array(1) {
["ntitle"]=>
string(35) "ntitle内容1"
}
}
[2]=>
array(5) {
["_index"]=>
string(7) "n_index"
["_type"]=>
string(6) "n_type"
["_id"]=>
string(1) "5"
["_score"]=>
float(0.23033649)
["_source"]=>
array(1) {
["ntitle"]=>
string(35) "ntitle内容3"
}
}
}
}
}
没有返回高亮部分,
回复内容:
以下代码是laravel+elastisearch-php(https://github.com/elastic/elasticsearch-php)实现的,但是不能返回高亮内容,网上看了https://segmentfault.com/a/1190000003010186 下面有一个例子提到高亮,但mmanos的不太会用,比如如何找指定索引下指定类型的某个查询?
不乱以上哪种方式,哪位朋友能指点一二,感谢!!!
$params=[
'index' => 'n_index',
'type' => 'n_type',
'body' => [
'query' => [
'match' => ['ntitle' => '要查询的词']
],
'highlight'=>[
'pre_tags'=>['', ''],
'post_tags'=>[' ', ''],
'fields'=>[
'ntitle'=>[]
]
]
]
];
$response = $this->client->search($params);
echo "";
var_dump($response);
echo "
";
以上代码可以查出以下结果
array(4) {
["took"]=>
int(6)
["timed_out"]=>
bool(false)
["_shards"]=>
array(3) {
["total"]=>
int(5)
["successful"]=>
int(5)
["failed"]=>
int(0)
}
["hits"]=>
array(3) {
["total"]=>
int(3)
["max_score"]=>
float(1.8223838)
["hits"]=>
array(3) {
[0]=>
array(5) {
["_index"]=>
string(7) "n_index"
["_type"]=>
string(6) "n_type"
["_id"]=>
string(1) "6"
["_score"]=>
float(1.8223838)
["_source"]=>
array(1) {
["ntitle"]=>
string(35) "ntitle内容2"
}
}
[1]=>
array(5) {
["_index"]=>
string(7) "n_index"
["_type"]=>
string(6) "n_type"
["_id"]=>
string(1) "7"
["_score"]=>
float(1.2087858)
["_source"]=>
array(1) {
["ntitle"]=>
string(35) "ntitle内容1"
}
}
[2]=>
array(5) {
["_index"]=>
string(7) "n_index"
["_type"]=>
string(6) "n_type"
["_id"]=>
string(1) "5"
["_score"]=>
float(0.23033649)
["_source"]=>
array(1) {
["ntitle"]=>
string(35) "ntitle内容3"
}
}
}
}
}
没有返回高亮部分,
内容总结
以上是互联网集市为您收集整理的elasticsearch-哪位朋友知道es-php或mmanos/laravel-search的查询结果高亮问题全部内容,希望文章能够帮你解决elasticsearch-哪位朋友知道es-php或mmanos/laravel-search的查询结果高亮问题所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。