emmetyang

导航

 

(1)索引settings:

{
"sql-dev-sug_product_test" : {
"settings" : {
"index" : {
"max_ngram_diff" : "8",
"refresh_interval" : "5s",
"number_of_shards" : "3",
"provided_name" : "sql-dev-sug_product_test",
"creation_date" : "1635839294054",
"analysis" : {
"filter" : {
"pinyin_filter" : {
"keep_joined_full_pinyin" : "true",
"lowercase" : "true",
"none_chinese_pinyin_tokenize" : "false",
"keep_none_chinese_in_joined_full_pinyin" : "true",
"keep_original" : "true",
"remove_duplicated_term" : "true",
"keep_first_letter" : "true",
"keep_separate_first_letter" : "false",
"type" : "pinyin",
"limit_first_letter_length" : "10",
"keep_full_pinyin" : "true"
},
"ngram_filter" : {
"type" : "ngram",
"min_gram" : "2",
"max_gram" : "10"
}
},
"analyzer" : {
"custom_analyzer" : {
"filter" : [
"ngram_filter"
],
"type" : "custom",
"tokenizer" : "ik_max_word"
},
"pinyin_analyzer" : {
"filter" : [
"pinyin_filter"
],
"type" : "custom",
"tokenizer" : "ngram"
}
}
},
"number_of_replicas" : "1",
"uuid" : "v5BwlG6HSI-m8MfBbYVq9w",
"version" : {
"created" : "7060199"
}
}
}
}
}

 

(2)  mapping

{
"sql-dev-sug_product_test" : {
"mappings" : {
"dynamic" : "false",
"_meta" : { },
"dynamic_date_formats" : [
"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
],
"dynamic_templates" : [
{
"message_field" : {
"path_match" : "message",
"match_mapping_type" : "string",
"mapping" : {
"norms" : false,
"type" : "text"
}
}
},
{
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"fields" : {
"keyword" : {
"ignore_above" : 256,
"type" : "keyword"
}
},
"norms" : false,
"type" : "text"
}
}
}
],
"date_detection" : true,
"numeric_detection" : true,
"properties" : {
"@timestamp" : {
"type" : "date"
},
"@version" : {
"type" : "keyword"
},
"barcode" : {
"type" : "keyword"
},
"brand" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"pinyin" : {
"type" : "text",
"term_vector" : "with_positions_offsets",
"analyzer" : "pinyin_analyzer",
"search_analyzer" : "pinyin"
}
},
"analyzer" : "custom_analyzer"
},
"brief" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
},
"analyzer" : "ik_smart"
},
"disease" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"effect" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"efficacy" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"geoip" : {
"dynamic" : "true",
"properties" : {
"ip" : {
"type" : "ip"
},
"latitude" : {
"type" : "half_float"
},
"location" : {
"type" : "geo_point"
},
"longitude" : {
"type" : "half_float"
}
}
},
"indication" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"new_time" : {
"type" : "date"
},
"product_name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"pinyin" : {
"type" : "text",
"term_vector" : "with_positions_offsets",
"analyzer" : "pinyin_analyzer",
"search_analyzer" : "pinyin"
},
"std" : {
"type" : "text",
"analyzer" : "standard"
}
},
"analyzer" : "custom_analyzer"
},
"product_status" : {
"type" : "integer"
},
"search_name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"short_name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"pinyin" : {
"type" : "text",
"term_vector" : "with_positions_offsets",
"analyzer" : "pinyin_analyzer",
"search_analyzer" : "pinyin"
},
"std" : {
"type" : "text",
"analyzer" : "standard"
}
},
"analyzer" : "custom_analyzer"
},
"symptom" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
},
"pinyin" : {
"type" : "text",
"term_vector" : "with_positions_offsets",
"analyzer" : "pinyin_analyzer",
"search_analyzer" : "pinyin"
},
"std" : {
"type" : "text",
"analyzer" : "standard"
}
},
"analyzer" : "custom_analyzer"
},
"un_autarky" : {
"type" : "integer"
},
"un_complimentary" : {
"type" : "integer"
},
"un_parcel" : {
"type" : "integer"
},
"un_pick_up" : {
"type" : "integer"
},
"un_promote" : {
"type" : "integer"
},
"un_refrigerate" : {
"type" : "integer"
},
"un_rx" : {
"type" : "integer"
},
"un_spec" : {
"type" : "integer"
},
"un_tcm" : {
"type" : "integer"
}
}
}
}
}

 

PUT _template/goods
{
"index_patterns":"goods*",
"settings": {
"index.number_of_replicas": "1",
"index.number_of_shards": "5",
"index.translog.flush_threshold_size": "512mb",
"index.translog.sync_interval": "60s",
"index.codec": "best_compression",
"analysis": {
"filter": {
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 50
},
"simple_pinyin_filter": {
"type": "pinyin",
"keep_first_letter": true,
"keep_separate_first_letter": false,
"keep_full_pinyin": false,
"keep_original": false,
"limit_first_letter_length": 50,
"lowercase": true
},
"full_pinyin_filter": {
"type": "pinyin",
"keep_first_letter": false,
"keep_separate_first_letter": false,
"keep_full_pinyin": true,
"none_chinese_pinyin_tokenize": true,
"keep_original": false,
"limit_first_letter_length": 50,
"lowercase": true
}
},
"char_filter": {
"charconvert": {
"type": "mapping",
"mappings_path": "char_filter_text.txt"
}
},
"tokenizer": {
"ik_max_word": {
"type": "ik_max_word",
"use_smart": true
}
},
"analyzer": {
"ngramIndexAnalyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"edge_ngram_filter",
"lowercase"
],
"char_filter": [
"charconvert"
]
},
"ngramSearchAnalyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase"
],
"char_filter": [
"charconvert"
]
},
"ikIndexAnalyzer": {
"type": "custom",
"tokenizer": "ik_max_word",
"char_filter": [
"charconvert"
]
},
"ikSearchAnalyzer": {
"type": "custom",
"tokenizer": "ik_max_word",
"char_filter": [
"charconvert"
]
},
"simplePinyinIndexAnalyzer": {
"tokenizer": "keyword",
"filter": [
"simple_pinyin_filter",
"edge_ngram_filter",
"lowercase"
]
},
"simplePinyinSearchAnalyzer": {
"tokenizer": "keyword",
"filter": [
"simple_pinyin_filter",
"lowercase"
]
},
"fullPinyinIndexAnalyzer": {
"tokenizer": "keyword",
"filter": [
"full_pinyin_filter",
"edge_ngram_filter",
"lowercase"
]
},
"fullPinyinSearchAnalyzer": {
"tokenizer": "keyword",
"filter": [
"full_pinyin_filter",
"lowercase"
]
}
}
}
}
}


DELETE goods_v1

PUT /goods_v1
{
"mappings": {
"doc":{
"properties" : {
"id":{
"type":"long"
},
"name" : {
"type": "text",
"analyzer": "ikIndexAnalyzer",
"fields": {
"ngram": {
"type": "text",
"analyzer": "ngramIndexAnalyzer"
},
"SPY": {
"type": "text",
"analyzer": "simplePinyinIndexAnalyzer"
},
"FPY": {
"type": "text",
"analyzer": "fullPinyinIndexAnalyzer"
}
}
},
"update_time" : {
"type":"date"
},
"deleted" : {
"type":"boolean"
}
}
}
}
}

PUT /goods_v1/_alias/goods
{
"is_write_index":true
}


GET goods/_search
{
"query": {
"constant_score": {
"filter": {
"bool": {
"filter": [
{
"term": {
"deleted": {
"value": false,
"boost": 1
}
}
},
{
"bool": {
"should": [
{
"match": {
"name.ngram": {
"query": "水果",
"operator": "OR",
"analyzer": "ngramSearchAnalyzer",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 5
}
}
},
{
"term": {
"name.SPY": {
"value": "水果",
"boost": 1
}
}
},
{
"wildcard": {
"name.SPY": {
"wildcard": "*水果*",
"boost": 0.8
}
}
},
{
"match_phrase": {
"name.FPY": {
"query": "水果",
"analyzer": "fullPinyinSearchAnalyzer",
"slop": 0,
"zero_terms_query": "NONE",
"boost": 1
}
}
},
{
"match": {
"name": {
"query": "水果",
"operator": "OR",
"analyzer": "ikSearchAnalyzer",
"prefix_length": 0,
"max_expansions": 50,
"minimum_should_match": "100%",
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"boost": 1
}
},
"sort": [
{
"id": {
"order": "desc"
}
}
]
}

 

GET goods/_search
{
"query": {
"constant_score": {
"filter": {
"bool": {
"filter": [
{
"term": {
"deleted": {
"value": false,
"boost": 1
}
}
},
{
"bool": {
"should": [
{
"match": {
"name.ngram": {
"query": "水果",
"operator": "OR",
"analyzer": "ngramSearchAnalyzer",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 5
}
}
},
{
"term": {
"name.SPY": {
"value": "水果",
"boost": 1
}
}
},
{
"wildcard": {
"name.SPY": {
"wildcard": "*水果*",
"boost": 0.8
}
}
},
{
"match_phrase": {
"name.FPY": {
"query": "水果",
"analyzer": "fullPinyinSearchAnalyzer",
"slop": 0,
"zero_terms_query": "NONE",
"boost": 1
}
}
},
{
"match": {
"name": {
"query": "水果",
"operator": "OR",
"analyzer": "ikSearchAnalyzer",
"prefix_length": 0,
"max_expansions": 50,
"minimum_should_match": "100%",
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"boost": 1
}
},
"sort": [
{
"id": {
"order": "desc"
}
}
]
}

 

posted on 2022-07-07 11:37  emmetyang  阅读(142)  评论(0)    收藏  举报