There is no such thing as perfect programming, but we shouldn’t be discouraged because programming is a constant pursuit of perfection.
Q: What’s special about Normalizer?
A:
Q: How do I use Normalizer?
A:
# normalizer
PUT /normalizer_test
{
"settings" : {
"analysis" : {
"normalizer" : {
"my_normalizer" : {
"type" : "custom"."char_filter" : {},
"filter" : ["lowercase"."asciifolding"}}}},"mappings" : {
"properties": {
"name" : {
"type" : "keyword"."normalizer" : "my_normalizer"
}
}
}
}
# 索引
POST /normalizer_test/_doc/1
{
"name" : "The BAR"} # index POST /normalizer_test/_doc/2
{
"name" : "bar"} # index POST /normalizer_test/_doc/3
{
"name" : "Bar"} # GET /normalizer_test/_search {"query" : {
"term" : {
"name" : "BAR"}}} # result {"took" : 11."timed_out" : false."_shards" : {
"total" : 1."successful" : 1."skipped" : 0."failed" : 0
},
"hits" : {
"total" : {
"value" : 3."relation" : "eq"
},
"max_score" : 0.13353139."hits": [{"_index" : "normalizer_test"."_type" : "_doc"."_id" : "1"."_score" : 0.13353139."_source" : {
"name" : "The BAR"}}, {"_index" : "normalizer_test"."_type" : "_doc"."_id" : "2"."_score" : 0.13353139."_source" : {
"name" : "bar"}}, {"_index" : "normalizer_test"."_type" : "_doc"."_id" : "3"."_score" : 0.13353139."_source" : {
"name" : "Bar"}} GET /normalizer_test/_search {"aggs": {
"normalizer_aggs" : {
"terms" : {
"field" : "name"."size" : 10}}}} # result {"took" : 11."timed_out" : false."_shards" : {
"total" : 1."successful" : 1."skipped" : 0."failed" : 0
},
"hits" : {
"total" : {
"value" : 3."relation" : "eq"
},
"max_score" : 1.0."hits": [{"_index" : "normalizer_test"."_type" : "_doc"."_id" : "1"."_score" : 1.0."_source" : {
"name" : "The BAR"}}, {"_index" : "normalizer_test"."_type" : "_doc"."_id" : "2"."_score" : 1.0."_source" : {
"name" : "bar"}}, {"_index" : "normalizer_test"."_type" : "_doc"."_id" : "3"."_score" : 1.0."_source" : {
"name" : "Bar"}}},"aggregations" : {
"normalizer_aggs" : {
"doc_count_error_upper_bound" : 0."sum_other_doc_count" : 0."buckets": [{"key" : "bar"."doc_count" : 3}]}}}Copy the code