現在のスタックは、Node.jsのv0.12.7がElasticsearch 1.7 APIとelasticsearch-JS> = 1.1.0で実行されているが含まれます。私は、関連する「入力」、「出力」の提案フィールドと「ペイロード」フィールドの両方を移入たElasticseach完了提案者のリターン提案は
elasticsearch.client.indices.create({
index: 'randomindex',
body: {
"settings": {
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
},
"my_english": {
"type": "english",
"stopwords": "_english_"
}
}
}
},
'mappings': {
'countries': {
'properties': {
'country': {
'type': 'string',
'fields': {
"autocomplete": { "type": "string", "index_analyzer": "autocomplete", "search_analyzer": "my_english" }
}
},
"suggest_countries": {
"type": "completion",
"index_analyzer": "simple",
"search_analyzer": "simple",
"payloads": true
}
}
},
'some_other_type': {
'properties': {
"field_1": {
"type": "date"
},
"field_2": {
"type": "string"
},
"suggest_some_other_field": {
"type": "completion",
"index_analyzer": "simple",
"search_analyzer": "simple",
"payloads": false
}
}
}
}
}
});
:
私の現在elasticsearch設定は、2種類の1つのインデックスを有するようにマッピングされます。
私からの提案を返すために、特定のインデックス・タイプを指定したいと思いますが、私はこれを行うときには、エラーを投げている:
elasticsearch.clients.suggest({
index: "randomindex",
type: "countries",
body: {
"suggest": {
text: query,
completion: {
"field": "suggest_countries"
}
}
}
});
は私が特定の型を参照/指定することができますどのような方法があります。方法を示唆している?
ESが投げているエラーを教えてください。 – Val
ノードで実行するとエラーは発生しません。応答オブジェクトに空のoptions配列を返します。しかし、ChromeのSense拡張のようなクライアントを介して '/ randomindex/countries/_suggest'エンドポイントにアクセスしようとすると、{{" suggest_countries ":{" text ":" a "、" completion ":{ "field": "suggest_countries"}}} 'それは' MapperParsingException [解析に失敗しました]のようなエラーを投げます。 ElasticsearchIllegalArgumentException [不明なフィールド名[text]、[出力、コンテキスト、入力、ウェイト、ペイロード]]のいずれかである必要があります。 –
エンドポイント '/ randomindex/countries/_search'に対してSenseをチェックして、すべてがそこにあるように見えるので、' autocomplete_countries'タイプで 'suggest_countries'フィールドを正しく設定していることを確認できます。 –