Skip to content

Instantly share code, notes, and snippets.

@duydo
Last active July 26, 2017 07:12
Show Gist options
  • Save duydo/ac4358ec3bddcaba02cf347369923674 to your computer and use it in GitHub Desktop.
Save duydo/ac4358ec3bddcaba02cf347369923674 to your computer and use it in GitHub Desktop.
ES mapping example to keep special chars
PUT test_index
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
"test_analyzer": {
"type":"custom",
"tokenizer": "whitespace",
"filter": ["lowercase", "test_filter"]
}
},
"filter": {
"test_filter": {
"type": "word_delimiter",
"type_table": [
"# => ALPHANUM",
"@ => ALPHANUM",
"$ => ALPHANUM"
]
}
}
}
},
"mappings": {
"test_doc": {
"properties": {
"content": {
"type": "string",
"analyzer": "test_analyzer"
}
}
}
}
}
PUT test_index/test_doc/1
{
"content": "I love #elasticsearch"
}
PUT test_index/test_doc/2
{
"content": "Elasticsearch is awsome"
}
GET test_index/test_doc/_search
{
"query": {
"match": {
"content": "#elasticsearch"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment