私はelasticsearchで新しく、ユーザーに5〜10個の一致する商品を提案するための電子商取引の検索を開発しようとしています。ElasticSearch:edge_ngramを使用して最初に表示するヒットを実際に表示する方法
ユーザーが入力している間に動作するはずだから、公式ドキュメントではedge_ngramとそれを使用していることが分かりました。しかし、テストのために検索したところ、結果は期待通りでした。
(我々のテストで)次の例を示しているように、画像に示されているように、用語に対する結果「Furadeira」(パワードリル)がパワードリル自体の前にアクセサリーを返します。どのように結果を向上させることができますか?文字列内で一致が見つかった場合でも、私は助けになるでしょう。
だから、これは私が今まで持っているコードです:事前に
//PUT example
{
"settings": {
"number_of_shards": 1,
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
},
"portuguese_stop": {
"type": "stop",
"stopwords": "_portuguese_"
},
"portuguese_stemmer": {
"type": "stemmer",
"language": "light_portuguese"
}
},
"analyzer": {
"portuguese": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"portuguese_stop",
"portuguese_stemmer"
]
},
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
}
}
}
/* mapping */
//PUT /example/products/_mapping
{
"products": {
"properties": {
"name": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "standard"
}
}
}
}
/* Search */
//GET /example/products/_search
{
"query" : {
"query_string": {
"query" : "furadeira",
"type" : "most_fields", // Tried without this aswell
"fields" : [
"name^8",
"model^10",
"manufacturer^4",
"description"
]
}
}
}
/* Product example */
// PUT example/products/38313
{
"name": \t "FITA VEDA FRESTA (ESPUMA 4503) 12X5 M [ H0000164055 ]",
"description": "Caracteristicas do produto:Ve…Diminui ruidos indesejaveis.",
"price":21.90,
"product_id": 38313,
"image": "http://placehold.it/200x200",
"quantity": 92,
"width": 20.200,
"height": \t 1.500,
"length": 21.500,
"weight": 0.082,
"model": "167083",
"manufacturer": "3M DO BRASIL"
}
感謝。
感謝を役に立てば幸い!残念ながら、私はブールを使ってみましたが、同じ結果を得ました。 –