Last active
July 26, 2017 07:12
-
-
Save duydo/ac4358ec3bddcaba02cf347369923674 to your computer and use it in GitHub Desktop.
ES mapping example to keep special chars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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