【发布时间】:2015-10-26 15:18:40
【问题描述】:
我们试图在 Elasticsearch 中找到不同的内部对象。这将是我们案例的最小示例。 我们遇到了类似以下映射的问题(更改类型或索引或添加新字段不会有问题,但结构应该保持原样):
{
"building": {
"properties": {
"street": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"house number": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"city": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"people": {
"type": "object",
"store": "yes",
"index": "not_analyzed",
"properties": {
"firstName": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
},
"lastName": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
}
}
}
}
}
}
假设我们有这个示例数据:
{
"buildings": [
{
"street": "Baker Street",
"house number": "221 B",
"city": "London",
"people": [
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Jane",
"lastName": "Doe"
}
]
},
{
"street": "Baker Street",
"house number": "5",
"city": "London",
"people": [
{
"firstName": "John",
"lastName": "Doe"
}
]
},
{
"street": "Garden Street",
"house number": "1",
"city": "London",
"people": [
{
"firstName": "Jane",
"lastName": "Smith"
}
]
}
]
}
当我们查询街道“贝克街”(以及所需的任何其他选项)时,我们期望得到以下列表:
[
{
"firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Jane",
"lastName": "Doe"
}
]
格式没有太大关系,但我们应该能够解析名字和姓氏。只是,由于我们的实际数据集要大得多,我们需要区分条目。
我们使用的是 Elasticsearch 1.7。
【问题讨论】:
标签: elasticsearch