Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
POST articles/_bulk
{"index":{}}
{"body":"lucene is very cool"}
{"index":{}}
{"body":"Elasticsearch builds on top of lucene"}
{"index":{}}
{"body":"Elasticsearch rocks"}
{"index":{}}
{"body":"elastic is the company behind ELK stack"}
{"index":{}}
{"body":"ELK stack rocks"}
{"index":{}}
{"body":"elasticsearch is rock solid"}
POST /articles/_search
{
"query": {
"match": {
"body": "lucen rock"
}
},
"suggest": {
"term-suggestion": {
"text": "lucen rock",
"term": {
"suggest_mode" : "popula",
"field": "body"
}
}
}
}
suggest_mode There are three values: missing context does not only occur term, will not return correct word, the word assessment rate more high Popular recommendation appeared, Always will recommend whether or not there is
POST /articles/_search
{
"suggest": {
"my-suggestion": {
"text": "lucne and elasticsear rock hello world",
"phrase": {
"field": "body",
"max_errors":"2",
"confidence":2,
"direct_generator" : [
{
"field" : "body",
"suggest_mode":"always"
}],
"highlight":{
"pre_tag":"<em>",
"post_tag":"</em>"
}
}
}
}
}
max_errors: Terms maximum number misspelled, Confidence: Returns the number of restrictions, the default is 1