1

https://gist.github.com/3442562の完全な要旨

私はアナライザーを持っています:

"analyzer" : {
            "lowercase_keyword" : {
                "type" : "custom",
                "tokenizer" : "keyword",
                "filter" : ["lowercase", "trim"]
            }
        }

マッピングで参照されている:

"location_countries" : {
                "properties" : {
                    "country" : {
                        "type" : "string",
                        "analyzer" : "lowercase_keyword"
                    }
                }
            }

また、フィルターまたはファセットで「国」フィールドを使用すると、フィールドは (正しく) キーワードとして扱われます。

curl -XGET 'localhost:9200/clinical_trials/_search?pretty=true' -d '
{
    "query" : {
        "term" : { "brief_title" : "dermatitis" }
    },
    "filter" : {
        "term" : { "country" : "united states" }
    },
    "facets" : {
        "tag" : {
            "terms" : { "field" : "country" }
        }
    }
}
'

ファセット結果:

"facets" : {
    "tag" : {
      "_type" : "terms",
      "missing" : 0,
      "total" : 1,
      "other" : 0,
      "terms" : [ {
        "term" : "united states",
        "count" : 1
      } ]
    }

マシンが再起動されるか、Elastic Search サービスが再起動されるまで、すべてが正常に機能します。再起動後、アナライザーが存在しないかのようにすべてのフィルターが機能しなくなります。

同じデータに対して同じクエリを実行すると、次のようになります。

"facets" : {
    "tag" : {
      "_type" : "terms",
      "missing" : 0,
      "total" : 2,
      "other" : 0,
      "terms" : [ {
        "term" : "united",
        "count" : 1
      }, {
        "term" : "states",
        "count" : 1
      } ]
    }

インデックスの _settings/_mappings を照会すると、アナライザーとマッピングは正しく定義されていますが、アナライザーは効果がないようです。

私は何を間違っていますか?

前もって感謝します!

4

1 に答える 1

0

国フィールドは複数のネストされたドキュメントに表示されますが、フィールドの 1 つのマッピングのみを設定しています。再起動後、elasticsearch はフィールドを別の順序でロードし、フィルター/ファセットを間違ったフィールドに適用します。

ファセットとフィルター フィールド名を完全に修飾すると、問題が解決します。

curl -XGET 'localhost:9200/clinical_trials/_search?pretty=true' -d '
{
    "query" : {
        "term" : { "brief_title" : "dermatitis" }
    },
    "filter" : {
        "term" : { "location_countries.country" : "united states" }
    },
    "facets" : {
        "tag" : {
            "terms" : { "field" : "location_countries.country" }
        }
    }
}
'

すべてのヘルプについて、 elasticsearch メーリング リストの Clint に感謝します。

于 2012-08-27T18:10:56.670 に答える