0
결과를 정렬하는 데 문제가 있습니다. ES에 넣어ElasticSearch - 정렬이 작동하지 않습니다.
다음curl -X PUT localhost:9200/companies -d '
{
"settings" : {
"analysis" : {
"analyzer" : {
"my_edge_ngram_analyzer" : {
"tokenizer" : "my_edge_ngram_tokenizer"
}
},
"tokenizer" : {
"my_edge_ngram_tokenizer" : {
"type" : "edgeNGram",
"min_gram" : "1",
"max_gram" : "5",
"token_chars": [ "letter", "digit" ]
}
}
}
},
"mappings": {
"company" : {
"properties" : {
"name" : { "type" : "string" },
"count" : {"type" : "long" },
"name_suggest" : {
"type" : "completion",
"index_analyzer": "my_edge_ngram_analyzer",
"search_analyzer": "my_edge_ngram_analyzer"
}
}
}
}
}'
된다 예 :
curl -X PUT localhost:9200/companies/company/1 -d '
{
"name" : "1800flowers",
"count": 1000,
"name_suggest" : {
"input" : [
"1800 flowers.Com, Inc",
"1800 Flowers","1800-Flowers.com",
"1 800 Flowers",
"www.1800flowers.com",
"1800Flowers.com",
"Inc,1-800-FLOWERS.COM",
"1-800-FLOWERS.COM, INC",
"1800Flowers",
"1800Flowers Inc",
"1800Flowers.com (Consultant)",
"1-800-FLOWERS","1800Flowers.com",
"1800FLOWERS INTERNATIONAL",
"1-800 Flowers",
"1-800 FLOWERS.COM, INC",
"1-800-FLOWERS, Inc",
"1800 flowers.com",
"1-800Flowers.com",
"1-800 flowers.com",
"1800 Flowers Inc"
],
"output" : "1800 Flowers"
}
}'
curl -X PUT localhost:9200/companies/company/2 -d '
{
"name" : "1800 Ruby",
"count": 10000,
"name_suggest" : {
"input" : [
"1800"
],
"output" : "1800 Ruby"
}
}'
이제
I 1800에서 텍스트 검색을 할 경우 분명, 내가 출력을 제공, 다시 이러한 개체를 모두 얻어야한다 "아래 내 설정이다 1800 꽃 ","1800 루비 ".
정말이 결과를 개수, 내림차순으로 정렬하여 "1800 Ruby", "1800 Flowers"가 있어야하지만 작동하지 않습니다.
curl -X POST localhost:9200/companies/_suggest -d '
{
"query":{
"companies" : {
"text" : "18",
"completion" : {
"field" : "name_suggest"
}
}
},
"sort": [ {"count": {"order": "desc"} } ]
}'
잘 작동하는 것 같습니다. 단순히 count 속성을 두 번 쓰는 대신 참조하는 방법을 알고 있습니까? – redrubia
슬프게도 아니오, 찾을 수 없었습니다. 완성의 한계 중 하나는 내가 알 수있는 한 제안합니다. –