嗨,朋友我想在我的網站做一個搜索欄。我有數以千計的公司文章。當我運行這段代碼: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。謝謝你的幫助。
謝謝你。你保存了一天:) –