php – 如何找到在elasticsearch中找到的结果的子类型?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 如何找到在elasticsearch中找到的结果的子类型?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1402字,纯文字阅读大概需要3分钟。
内容图文
大家好,提前谢谢,
我以下列方式在elasticsearch服务器上索引数据
{
'main_index':{
'type':[{
'name':'john deo',
'type':'accountant',
'description':'john deo is a great person',
'address':'somewhere in the world'
},
{
'name':'calvin kalvin',
'type':'designer',
'description':'calvin kalvin is john deo's best friend',
'address':'somewhere near'
}]
}
}
我的查询是,当我搜索伟大的人时,它也应该返回它的子类型,例如名称或类型或描述或地址
例如.:
http:// localhost:9200 / some-index / type?q =好人
因此,除了完整的结果,它还应返回其子类型ie :: description.我试过荧光笔,但没用.
请帮忙.
解决方法:
这个怎么样?
GET /my_index/type/_search?q=great person
{
"highlight": {
"fields": {"name": {},"type": {},"description": {},"address": {}}
}
}
哪个给你:
"hits": [
{
"_index": "my_index",
"_type": "type",
"_id": "1",
"_score": 0.10848885,
"_source": {
"name": "john deo",
"type": "accountant",
"description": "john deo is a great person",
"address": "somewhere in the world"
},
"highlight": {
"description": [
"john deo is a <em>great</em> <em>person</em>"
]
}
}
]
如果你把“世界”放在搜索查询中(所以q =伟人世界),它会给你:
"hits": [
{
"_index": "my_index",
"_type": "type",
"_id": "1",
"_score": 0.13287117,
"_source": {
"name": "john deo",
"type": "accountant",
"description": "john deo is a great person",
"address": "somewhere in the world"
},
"highlight": {
"address": [
"somewhere in the <em>world</em>"
],
"description": [
"john deo is a <em>great</em> <em>person</em>"
]
}
}
]
内容总结
以上是互联网集市为您收集整理的php – 如何找到在elasticsearch中找到的结果的子类型?全部内容,希望文章能够帮你解决php – 如何找到在elasticsearch中找到的结果的子类型?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。