Created
February 26, 2019 12:35
-
-
Save djptek/e8cb2878cba82b353ec69efd829ee490 to your computer and use it in GitHub Desktop.
case insensitive keyword search
This file contains hidden or 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
DELETE test | |
PUT test | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"my_case_insensitive_keyword": { | |
"type": "custom", | |
"char_filter": [], | |
"tokenizer": "keyword", | |
"filter": [ | |
"lowercase" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"_doc": { | |
"properties": { | |
"my_kw": { | |
"type": "text", | |
"analyzer": "my_case_insensitive_keyword", | |
"fielddata":true | |
} | |
} | |
} | |
} | |
} | |
PUT test/_doc/abc | |
{"my_kw":"abc"} | |
PUT test/_doc/ABC | |
{"my_kw":"ABC"} | |
PUT test/_doc/xYz | |
{"my_kw":"xYz"} | |
GET test/_search | |
GET test/_search | |
{ | |
"query": { | |
"match": { | |
"my_kw": "abc" | |
} | |
} | |
} | |
GET test/_search | |
{ | |
"query": { | |
"match": { | |
"my_kw": "ABC" | |
} | |
} | |
} | |
GET test/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"my_kw_count": { | |
"cardinality": { | |
"field": "my_kw" | |
} | |
} | |
} | |
} | |
GET test/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"my_kw_count": { | |
"terms": { | |
"field": "my_kw" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment