elasticsearch:在方面计数错误



不确定这是bug还是我遗漏了什么。但是Terms方面返回了错误的术语数计数。

我有一个字段有str_tag_analyzer

我想从字段中获取Tag Cloud。我想获得前20个标签及其计数(它们出现的次数)

Terms方面为这个案例寻找了解决方案。我知道Terms方面查询中的size参数控制返回多少标签。

当我运行不同大小的术语方面查询时,会得到意外的结果。以下是我的一些查询及其结果。

查询1

curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d '
{
query : {
  "nested" : {
    "query" : {
      "field" : {
        "gsid" : 222
      }
    },
    "path" : "medals"
  }
}, from: 0, size: 0
,
facets: {
"tags" : { "terms" : {"field" : "field_val_t", size: 1} }
}
}'

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "failed" : 0
  },
  "hits" : {
    "total" : 189,
    "max_score" : 1.0,
    "hits" : [ ]
  },
  "facets" : {
    "tags" : {
      "_type" : "terms",
      "missing" : 57,
      "total" : 331,
      "other" : 316,
      "terms" : [ {
        "term" : "hyderabad",
        "count" : 15
      } ]
    }
  }

查询2

curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d '
{
query : {
  "nested" : {
    "query" : {
      "field" : {
        "gsid" : 222
      }
    },
    "path" : "medals"
  }
}, from: 0, size: 0
,
facets: {
"tags" : { "terms" : {"field" : "field_val_t", size: 3} }
}
}'

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "failed" : 0
  },
  "hits" : {
    "total" : 189,
    "max_score" : 1.0,
    "hits" : [ ]
  },
  "facets" : {
    "tags" : {
      "_type" : "terms",
      "missing" : 57,
      "total" : 331,
      "other" : 282,
      "terms" : [ {
        "term" : "playing",
        "count" : 20
      }, {
        "term" : "hyderabad",
        "count" : 15
      }, {
        "term" : "pune",
        "count" : 14
      } ]
    }
  }
}

查询3

curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d '
{
query : {
  "nested" : {
    "query" : {
      "field" : {
        "gsid" : 222
      }
    },
    "path" : "medals"
  }
}, from: 0, size: 0
,
facets: {
"tags" : { "terms" : {"field" : "field_val_t", size: 10} }
}
}'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 3,
    "successful" : 3,
    "failed" : 0
  },
  "hits" : {
    "total" : 189,
    "max_score" : 1.0,
    "hits" : [ ]
  },
  "facets" : {
    "tags" : {
      "_type" : "terms",
      "missing" : 57,
      "total" : 331,
      "other" : 198,
      "terms" : [ {
        "term" : "playing",
        "count" : 20
      }, {
        "term" : "hyderabad",
        "count" : 19
      }, {
        "term" : "bangalore",
        "count" : 18
      }, {
        "term" : "pune",
        "count" : 16
      }, {
        "term" : "chennai",
        "count" : 16
      }, {
        "term" : "games",
        "count" : 13
      }, {
        "term" : "testing",
        "count" : 11
      }, {
        "term" : "cricket",
        "count" : 9
      }, {
        "term" : "singing",
        "count" : 6
      }, {
        "term" : "movies",
        "count" : 5
      } ]
    }
  }
}

我有以下顾虑1.第一个查询给出了计数为15的标签,但存在另一个计数为20的标签(可以在查询2和3中看到)。所以它必须返回计数为20的"正在播放"标签。2.第二个查询返回"hyderabad"标签的计数为15,但第三个查询返回相同标签的计数19。

如果您需要任何其他信息,如地图、ES中的数据,请告诉我。感谢

这是一个已知的问题。解决方法是使用一个碎片,或者要求更多的术语,然后再显示。

相关内容

最新更新