Skip to content

Instantly share code, notes, and snippets.

@mghignet
Created August 24, 2018 08:26
Show Gist options
  • Select an option

  • Save mghignet/f36f2efe9bb555b13b0adbe36444ca60 to your computer and use it in GitHub Desktop.

Select an option

Save mghignet/f36f2efe9bb555b13b0adbe36444ca60 to your computer and use it in GitHub Desktop.
Kibana commands to setup an Elastic index that handles autocompletion πŸ‘
PUT customer
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"analysis": {
"filter": {
"min_length_filter": {
"type": "length",
"min": 2
},
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"edge_ngram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"edge_ngram_filter"
]
},
"min_length_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"min_length_filter"
]
}
}
}
},
"mappings": {
"default": {
"properties": {
"fullname": {
"type": "text",
"analyzer": "edge_ngram_analyzer",
"search_analyzer": "min_length_analyzer"
},
"firstname": {
"type": "text",
"copy_to": "fullname"
},
"lastname": {
"type": "text",
"copy_to": "fullname"
}
}
}
}
}
PUT customer/default/jeandupont
{
"id": "1234567890",
"firstname": "Jean",
"lastname": "Dupont",
"age": 34
}
POST _search
{
"query": {
"term": {
"fullname": "jean"
}
}
}
POST _search
{
"_source": ["firstname", "lastname"],
"query": {
"match": {
"fullname": {
"query": "dup j",
"operator": "and"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment