First at all, I would like to say that I use Elasticsearch and Logstash 6.2 and due the big update, a lot of topics are not compatible. I looked twice before posting mine. :)
I use MySQL as database and with Logstash 6.2 and JDBC, I transfer automatically my rows in Elasticsearch 6.2. Everything works fine from this side !
However, I'm trying to use Elasticsearch as search engine in a Node/Express' project. I would like to create an autocomplete searchbar as describes in this tutorial Leveraging the Power of Elasticsearch: Autocomplete and Fuzzy Search .
The problem is I can't enable auto completion because my data loaded from MySQL are as String and not as Completion type:
Illegal_argument_exception, reason:Field [extid] is not a completion suggest field, status:400
So for the getSuggestions function, I try this :
function getSuggestions(text, size){
return elasticClient.search({
index: indexName,
type: indexType,
body: {
suggest: {
extidSuggester: {
text: text+'~',
term: {
field: "extid",
size: size
}
},
nameSuggester: {
text: text+'~',
term: {
field: "name",
size: size
}
}
}
}
});
}
which does not give me autocompletion.
A solution could be to filter the targeted columns in the Logstash conf and force to the completion's type. Is someone know how to perform that ?
Is there another solution to resolve my problem ?
I finally answer myself.
When I created the mapping, I used a default mapping found on github .
I added to this mapping the type completion for the needed fields and it resolved my issue.
Simple as that !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.