Skip to content

Instantly share code, notes, and snippets.

@jprante
Created March 5, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jprante/7503cb60e514d1ea46a4 to your computer and use it in GitHub Desktop.
Save jprante/7503cb60e514d1ea46a4 to your computer and use it in GitHub Desktop.
I love ES
DELETE /test
PUT /test/
{
"settings": {
"analysis": {
"char_filter": {
"emoticon": {
"type": "mapping",
"mappings": [
"<3=>❤️"
]
}
},
"filter" : {
"heart" : {
"type" : "synonym",
"synonyms" : [
"❤ => ❤,love"
]
}
},
"analyzer": {
"myanalyzer": {
"type": "custom",
"tokenizer": "whitespace",
"char_filter": [
"emoticon"
],
"filter" : [
"lowercase",
"heart"
]
}
}
}
},
"mappings": {
"doc": {
"properties": {
"text": {
"type": "string",
"analyzer": "myanalyzer"
}
}
}
}
}
PUT /test/doc/1
{
"text" : "I <3 ES"
}
PUT /test/doc/2
{
"text" : "I ❤ ES"
}
PUT /test/doc/3
{
"text" : "I love ES"
}
POST /test/doc/_search
{
"query" : {
"match" : {
"text" : "I <3 ES"
}
}
}
POST /test/doc/_search
{
"query" : {
"match" : {
"text" : "I ❤ ES"
}
}
}
POST /test/doc/_search
{
"query" : {
"match" : {
"text" : "I love ES"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment