1

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

我有一个有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. 第二次查询将“海得拉巴”标签的计数返回为 15,但第三次查询将同一标签的计数返回为 19。

如果您需要任何其他信息,例如映射、ES 中存在的数据,请告诉我。谢谢

4

1 回答 1

1

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

于 2013-07-01T19:32:25.980 回答