【问题标题】:elasticsearch: wrong count in terms facetelasticsearch:在方面的错误计数
【发布时间】:2013-07-01 10:29:28
【问题描述】:

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

我有一个包含str_tag_analyzer 的字段。

我想从现场获取标签云。我想获得前 20 个标签及其计数(它们出现了多少次)

术语方面为这种情况寻找解决方案。我知道条款方面查询中的 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 中存在的数据,请告诉我。 谢谢

【问题讨论】:

    标签: curl elasticsearch


    【解决方案1】:

    这是一个known issue。解决方法是使用单个分片或要求更多的术语然后您打算显示。

    【讨论】:

    • 从 0.90.6 版开始你也可以使用shard_size
    • 这不是实现它的最佳方式。使用单个分片可能会对性能产生影响。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多