0
下面是一個簡單的上下文:Elasticsearch - 自動完成與修正
curl -XPUT localhost:9200/testso -d '{
"mappings": {
"person": {
"properties": {
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
curl -XPUT 'http://localhost:9200/testso/person/1' -d '{
"name" : "foo bar",
"context_id" : 1
}'
curl -XPUT 'http://localhost:9200/testso/person/2' -d '{
"name" : "fou bar",
"context_id" : 1
}'
curl -XPUT 'http://localhost:9200/testso/person/3' -d '{
"name" : "foo baz",
"context_id" : 2
}'
我正在尋找有關方法來幫助用戶以「正確」的寫作和自動完成它,在一個特定的背景。
Exemples,尋找背景1:
"foo bar" => [ "foo bar", "fou bar" ]
"fou bar" => [ "foo bar", "fou bar" ]
"foo" => [ "foo", "fou", "foo bar", "fou bar" ]
"fol" => [ "foo", "fou", "foo bar", "fou bar" ]
我已經測試了一些elasticsearch functionnalities ... suggest
不採取"query"
選項帳戶:
curl -XGET http://localhost:9200/testso/person/_search?search_type=count -d '{
"query" : { "query_string": { "query": "context_id:2" } },
"suggest": {
"text" : "foo baz",
"my_suggestion": {
"term" : {
"field" : "name"
}
}
}
}'
...返回建議「富bar「和」fou bar「,它屬於上下文1.
你對如何查詢elasticsearch返回事物有任何想法l這個嗎?一個具體的映射?其他功能性?一個特定的索引器?