현재 스택은 Node.js를 v0.12.7가 Elasticsearch 1.7 API와 elasticsearch-JS> = 1.1.0 실행이 포함됩니다.Elasticseach 완료 SUGGESTER 반환 제안
나의 현재 elasticsearch 설정은 2 종류의 1 개 인덱스가 매핑되어
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.clients.suggest({
index: "randomindex",
type: "countries",
body: {
"suggest": {
text: query,
completion: {
"field": "suggest_countries"
}
}
}
});
가 내가/지정의 특정 형식을 참조 할 수있는 방법입니다. 방법을 제안 하는가?
ES가 던지고있는 오류를 공유하십시오. – Val
노드에서 실행할 때 오류가 없습니다. 응답 객체에 빈 옵션 배열을 반환합니다. 그러나 Chrome의 Sense 확장과 같은 클라이언트를 통해'/ randomindex/countries/_suggest' 엔드 포인트에 도달하려고하면 {{ "suggest_countries": { "text": "a", "completion": { "field": "suggest_countries"}}}'MapperParsingException [구문 분석하지 못했습니다]와 같은 오류가 발생합니다. 중첩 : ElasticsearchIllegalArgumentException [알 수없는 필드 이름 [텍스트], [출력, 컨텍스트, 입력, 가중치, 페이로드]] 중 하나 여야합니다. –
엔드 포인트'/ randomindex/countries/_search'에 대해 Sense를 체크했기 때문에'suggest_countries' 필드가'autocomplete_countries' 타입에 올바르게 채워 졌는지 확인할 수 있습니다. 모든 것이 거기에있는 것처럼 보입니다. –