1

これがバグなのか、何かが足りないのかわかりません。しかし、用語ファセットは、用語の数に対して間違った数を返しています。

を持つフィールドがありますstr_tag_analyzer

フィールドからタグクラウドを取得したい。トップ20のタグとそのカウント(出現回数)を取得したい.

用語ファセットは、この場合の解決策に見えました。タームズ ファセット クエリのサイズ パラメータが、返されるタグの数を制御することを理解しています。

サイズの異なる用語ファセット クエリを実行すると、予期しない結果が得られます。ここに私のクエリとその結果のいくつかがあります。

クエリ 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 で確認できます)。2. 2 番目のクエリは「hyderabad」タグのカウントを 15 として返しますが、3 番目のクエリは同じタグのカウントを 19 として返します。

マッピング、ES に存在するデータなど、他の情報が必要な場合はお知らせください。ありがとう

4

1 に答える 1