嗨,朋友我想在我的网站做一个搜索栏。我有数以千计的公司文章。当我运行这段代码:Elasticsearch聚合和过滤器
GET articles/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "assistant",
"fields": ["title"]
}
}
]
}
},
"size": 0,
"aggs": {
"by_company": {
"terms": {
"field": "company.keyword",
"size": 10
}
}
}
}
结果是:所以现在
"aggregations": {
"by_company": {
"doc_count_error_upper_bound": 5,
"sum_other_doc_count": 409,
"buckets": [
{
"key": "University of Miami",
"doc_count": 6
},
{
"key": "Brigham & Women's Hospital(BWH)",
"doc_count": 4
},
我想迈阿密大学的过滤器的文章使我运行下面的查询:
GET indeed_psql/job/_search
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "assistant",
"fields": ["title"]
}
}
],
"filter": {
"term": {
"company.keyword": "University of Miami"
}
}
}
},
"size": 0,
"aggs": {
"by_company": {
"terms": {
"field": "company.keyword",
"size": 10
}
}
}
}
但现在结果是:
"aggregations": {
"by_company": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "University of Miami",
"doc_count": 7
}
]
}
为什么在以前的聚合中突然有7个是6?其他大学过滤器也会发生这种情况。我究竟做错了什么 ?我没有使用标准的标记语言,并使用english_stemmer,english_stopwords,english_keywords。谢谢你的帮助。
谢谢你。你保存了一天:) –