を使用した場合それでは、私はこのように定義されたElasticSearchインデックスを持っているとしましょう:ElasticSearch:奇妙な検索行動雪だるまアナライザ
curl -XPUT 'http://localhost:9200/test' -d '{
"mappings": {
"example": {
"properties": {
"text": {
"type": "string",
"analyzer": "snowball"
}
}
}
}
}'
curl -XPUT 'http://localhost:9200/test/example/1' -d '{
"text": "foo bar organization"
}'
私は雪だるま式アナライザで「FOO団体」、期待通り両方のキーワードマッチを検索:
curl -XGET http://localhost:9200/test/example/_search -d '{
"query": {
"text": {
"_all": {
"query": "foo organizations",
"analyzer": "snowball"
}
}
},
"highlight": {
"fields": {
"text": {}
}
}
}'
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.015912745,
"hits": [
{
"_index": "test",
"_type": "example",
"_id": "1",
"_score": 0.015912745,
"_source": {
"text": "foo bar organization"
},
"highlight": {
"text": [
"<em>foo</em> bar <em>organization</em>"
]
}
}
]
}
}
しかし、ときに私は、私は非常に奇妙である、まったく結果を得ることはありませんだけで「組織」を検索:
curl -XGET http://localhost:9200/test/example/_search -d '{
"query": {
"text": {
"_all": {
"query": "organizations",
"analyzer": "snowball"
}
}
},
"highlight": {
"fields": {
"text": {}
}
}
}'
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
私は「バー」を検索する場合
しかし、まだヒット:
curl -XGET http://localhost:9200/test/example/_search -d '{
"query": {
"text": {
"_all": {
"query": "bars",
"analyzer": "snowball"
}
}
},
"highlight": {
"fields": {
"text": {}
}
}
}'
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.10848885,
"hits": [
{
"_index": "test",
"_type": "example",
"_id": "1",
"_score": 0.10848885,
"_source": {
"text": "foo bar organization"
},
"highlight": {
"text": [
"foo <em>bar</em> organization"
]
}
}
]
}
}
私は「バー」と「組織」の違いを推測された「組織」は茎されていることを「バー」がある一方、「臓器」へそれ自体にはまった。しかし、2番目の検索ヒットを得るためには、どのように適切な振る舞いをするのですか?
これは意味があります、ありがとう。私のインデックスにある実際のトークンを見る方法はありますか?そして、私はESに** all **列のために雪ボールを使うように伝えることができますか? – tycooon
インデックス内の実際のトークンを調べる簡単な方法はありませんが、Analyze API(http://www.elasticsearch.org/guide/reference/api/admin-indices- analyze.html)。インデックス作成時に* _all *フィールドにスノーボールアナライザーを設定することができます。https://gist.github.com/2043721あるいは、スノーボールは、すべてのフィールドhttps://gist.github.com/2043697のデフォルトのアナライザーとして設定することができます。 – imotov