我现在有几个小时的问题,因为我没有得到解决。
我需要进行分面搜索以获取所有视频播放列表的列表。
视频可以有多个播放列表,每个播放列表都有" name"," position"。这就是它嵌套的原因。
这是我的映射:
{
"mappings" : {
"test" : {
"properties" : {
"playlists": {
"type": "nested",
"properties" : {
"name" : {
"type": "multi_field",
"fields" : {
"name": {"type" : "string", "index" : "analyzed", "store": "yes"},
"untouched" : {"type" : "string", "index" : "not_analyzed"}
}
},
"position" : {
"type" : "string"
}
}
}
}
}
}
}
问题是它包含" - "时的名称。例如" de-classic"通过以下方面搜索:
{
"query": {
"match_all": {}
},
"facets": {
"playlists": {
"terms": {
"field": "playlists.name",
"size": 1000
}
}
}
}
我的方面搜索返回一个条目" de"和#34;经典":
facets: {
playlists: {
_type: terms,
missing: 0,
total: 2,
other: 0,
terms: [
{
term: de
count: 1
},
{
term: classics
count: 1
}
]
}
}
我在这里放了一个简化的要点:https://gist.github.com/axeff/bacf3bb2119f7589e612
Elasticsearch v1.1.1
修改
插入后的映射看起来与我创建的映射不同:
curl localhost:9200 / videos / test / _mapping?pretty = true:
{
"videos" : {
"mappings" : {
"test" : {
"properties" : {
"playlists" : {
"properties" : {
"name" : {
"type" : "string"
},
"position" : {
"type" : "string"
}
}
}
}
}
}
}
}
答案 0 :(得分:0)
解决了我的问题:
{
"query": {
"match_all": {}
},
"facets": {
"playlists": {
"terms": {
"field": "playlists.name",
"size": 1000
},
"nested": "playlists" // <- that's what I was missing!
}
}
}