【发布时间】:2017-05-17 22:11:27
【问题描述】:
我是弹性搜索的新手,我第一次使用它来索引我的数据并对其执行搜索。
我编写了这段代码来查找索引中的术语计数:
{
{
"size": 0
},
"aggs": {
"BookID": {
"terms": {
"field": "bookID",
"size": 100000
},
"aggs": {
"total_Chapter": {
"nested": {
"path": "chapterData"
},
"aggs": {
"termsInChapter": {
"filters": {
"filters": {
"king": {
"query_string": {
"query": "king",
"default_field": "chapter.data"
}
},
"queen": {
"query_string": {
"query": "queen",
"default_field": "chapter.data"
}
},
"apple": {
"query_string": {
"query": "apple",
"default_field": "chapter.data"
}
}
}
}
},
"termsInChapter_count": {
"value_count": {
"field": "termsInChapter"
}
}
}
}
}
}
}
}
但不知何故,结果返回 0。我不知道我在此查询中做错了什么。
这是该查询的部分输出:
"aggregations": {
"BookID": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1,
"doc_count": 1,
"total_Chapter": {
"doc_count": 23,
"termsInChapter": {
"buckets": {
"apple": {
"doc_count": 2
},
"king": {
"doc_count": 1
},
"queen": {
"doc_count": 1
}
}
},
"termsInChapter_count": {
"value": 0 <=========This should return 3
}
}
},
{
"key": 2,
"doc_count": 1,
"total_Chapter": {
"doc_count": 23,
"termsInChapter": {
"buckets": {
"apple": {
"doc_count": 0
},
"king": {
"doc_count": 3
},
"queen": {
"doc_count": 2
}
}
},
"termsInChapter_count": {
"value": 0
}
}
},
提前感谢您的帮助。
【问题讨论】:
标签: elasticsearch nest