私はelasticsearch帯状疱疹を使って小さな検索アプリの自動補完機能を構築しました。私がアナライザとトークンをテストすると、すべてが正しく設定されているようです。なぜ0の結果が得られるのですか
PUT /autocomplete
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"analysis": {
"filter": {
"autocomplete_shingles_filter": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 5,
"output_unigrams": false
}
},
"analyzer": {
"autocomplete_shingles_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_shingles_filter"
]
}
}
}
}
}
GET /autocomplete/_analyze?analyzer=autocomplete_shingles_analyzer&text=2010 toyota camry
しかし、その後、私は実際にインデックスとのマッピングを作成し、_allフィールドと一致クエリを使用するために行くとき、私は0結果ここ
"mappings": {
"suggestions": {
"_all": {
"enabled": true,
"index_analyzer": "autocomplete_analyzer",
"search_analyzer": "autocomplete_analyzer"
},
"properties": {
"makes": {
"type": "string",
"include_in_all": true
},
"models": {
"type": "string",
"include_in_all": true
},
"years": {
"type": "string",
"include_in_all": true
}
}
}
}
}
を取得するには、データのサンプルである
PUT /autocomplete/suggestions/_bulk
{"index": {"_id":"1"}}
{"years": ["2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017"]}
{"index": {"_id":"2"}}
{"makes": "Acura", "models": ["Legend Integra NSX Vigor TL RL SLX CL MDX RSX TSX RDX ZDX"]}
{"index": {"_id":"3"}}
{"makes": "Alfa Romeo", "models": ["164 Spider"]}
{"index": {"_id":"4"}}
{"makes": "Aston Martin", "models": ["DB9 Vanquish S DB9 Volante V8 Vantage Vantage DBS Rapide V8 Vantage S V12 Vantage Virage"]}
{"index": {"_id":"5"}}
{"makes": "Alfa Romeo", "models": ["164 Spider"]}
検証アナライザーAPIを使用すると、実際にインデックス、マッピング、クエリを作成するときに、なぜこれが機能するのですか。結果は0ですか?私は間違って何をしていますか?
UPDATE
{
"query": {
"match": {
"_all": {
"query": "2010 acura integra",
"operator": "and"
}
}
}
}
UPDATE 2私は、私はそれを考え出したと信じて、私は演算子を使用していた。そして - すべての条件が動作しないすべてのフィールドでなければならなかった意図います。演算子を削除すると結果が得られます。しかし、私のテストでは、マルチマッチクエリがこれに適しているようです。なぜなら、1)私はフィールドを上げることができます2)_allフィールドを使う必要はありません3)時間の経過とともにそれを微調整するための質問、そこに正しいトラックがあるのでしょうか?
あなたが使用しているクエリは何ですか? –
@AndreiStefan、_allフィールドのUPDATE、matchクエリを参照してください - 使用するクエリが良いですか? – user3125823