【发布时间】:2015-07-11 03:40:41
【问题描述】:
我的 Elasticsearch 节点中有一个文档,其中包含有关某人联系人的信息:
"contacts": [
{
"id": 1,
"address": "address1",
"tel": "40071322",
"doctor_id": 1,
"type_id": 1,
"lng": "51.374720",
"lat": "35.781986",
"city_id": 186,
"province_id": 8,
"hour_about": null,
"place_name": null
},
{
"id": 2,
"address": "address2",
"tel": null,
"doctor_id": 1,
"type_id": 2,
"lng": "51.520313",
"lat": "35.726983",
"city_id": 186,
"province_id": 8,
"hour_about": null,
"place_name": null
},
{
"id": 3,
"address": "address3",
"tel": null,
"doctor_id": 1,
"type_id": 2,
"lng": "51.456368",
"lat": "35.797505",
"city_id": 186,
"province_id": 8,
"hour_about": null,
"place_name": null
}
]
我想运行term 过滤器 来查找在其contacts 字段中包含city_id 或X 的文档。当字段本身有像上面这样的子字段时,我应该怎么做这个查询?
首选使用elasticsearch php api =)
感谢您的帮助。
【问题讨论】:
-
到目前为止你都尝试过做什么?
-
@Ashesh,我试过
'term' => array ( 'contacts' => intval($value) ) -
@Ashesh,我想我应该使用
term过滤器,对吗?导致它的 1 值 -
包括您使用的映射。您是否使用嵌套文档或父子对象来映射联系人。查询将取决于您使用的映射类型。
标签: php json api search elasticsearch