There is no such thing as perfect programming, but we shouldn’t be discouraged because programming is a constant pursuit of perfection.
Q: What are the parameters of ES Mapping?
A:
Q: What are the characteristics of analyzer?
A:
Q: How is Analyzer used?
A:
# analyzer # Custom analyzer PUT /analyzer_test {"settings" : {
"analysis" : {
"analyzer" : {
"my_analyzer" : {
"type" : "custom"."tokenizer" : "standard"."filter" : ["lowercase"]},"my_stop_analyzer" : {
"type" : "custom"."tokenizer" : "standard"."filter" : ["lowercase"."english_stop"]}},"filter" : {
"english_stop" : {
"type" : "stop"."stopwords" : "_english_"}}}},"mappings" : {
"properties" : {
"name1" : {
"type" : "text"."analyzer": "my_analyzer"
},
"name2" : {
"type" : "text"."analyzer" : "my_analyzer"."search_analyzer" : "my_stop_analyzer"
},
"name3" : {
"type" : "text"."analyzer" : "my_analyzer"."search_analyzer" : "my_stop_analyzer"."search_quote_analyzer" : "my_analyzer"
}
}
}
}
# 索引
POST /analyzer_test/_doc/1
{
"name1" : "this is my hello good"."name2" : "this is my hello good"."name3" : "this is my hello good"} # index POST /analyzer_test/_doc/2
{
"name1" : "a hello good"."name2" : "a hello good"."name3" : "a hello good"} GET /analyzer_test/_search {"query" : {
"match_phrase" : {
"name1" : "a hello good"}}} # result {"took" : 0."timed_out" : false."_shards" : {
"total" : 1."successful" : 1."skipped" : 0."failed" : 0
},
"hits" : {
"total" : {
"value" : 1."relation" : "eq"
},
"max_score" : 1.178298."hits": [{"_index" : "analyzer_test"."_type" : "_doc"."_id" : "2"."_score" : 1.178298."_source" : {
"name1" : "a hello good"."name2" : "a hello good"."name3" : "a hello good"}} GET /analyzer_test/_search {"query" : {
"match_phrase" : {
"name2" : "a hello good"}}} # result {"took" : 0."timed_out" : false."_shards" : {
"total" : 1."successful" : 1."skipped" : 0."failed" : 0
},
"hits" : {
"total" : {
"value" : 2."relation" : "eq"
},
"max_score" : 0.40618476."hits": [{"_index" : "analyzer_test"."_type" : "_doc"."_id" : "2"."_score" : 0.40618476."_source" : {
"name1" : "a hello good"."name2" : "a hello good"."name3" : "a hello good"}}, {"_index" : "analyzer_test"."_type" : "_doc"."_id" : "1"."_score" : 0.33081025."_source" : {
"name1" : "this is my hello good"."name2" : "this is my hello good"."name3" : "this is my hello good"GET /analyzer_test/_search {GET /analyzer_test/_search}"query" : {
"match_phrase" : {
"name3" : "a hello good"}}} # result {"took" : 0."timed_out" : false."_shards" : {
"total" : 1."successful" : 1."skipped" : 0."failed" : 0
},
"hits" : {
"total" : {
"value" : 1."relation" : "eq"
},
"max_score" : 1.178298."hits": [{"_index" : "analyzer_test"."_type" : "_doc"."_id" : "2"."_score" : 1.178298."_source" : {
"name1" : "a hello good"."name2" : "a hello good"."name3" : "a hello good"GET /analyzer_test/_search {"query" : {
"match" : {
"name3" : "a hello good"}}} # result {"took" : 1."timed_out" : false."_shards" : {
"total" : 1."successful" : 1."skipped" : 0."failed" : 0
},
"hits" : {
"total" : {
"value" : 2."relation" : "eq"
},
"max_score" : 0.40618476."hits": [{"_index" : "analyzer_test"."_type" : "_doc"."_id" : "2"."_score" : 0.40618476."_source" : {
"name1" : "a hello good"."name2" : "a hello good"."name3" : "a hello good"}}, {"_index" : "analyzer_test"."_type" : "_doc"."_id" : "1"."_score" : 0.33081025."_source" : {
"name1" : "this is my hello good"."name2" : "this is my hello good"."name3" : "this is my hello good"}}]}}Copy the code