场景,我想实现大小写区分查询,但是es默认都会将字段的内容转换为小写。 想自定义标记过滤器,但是这个lowercase 是boolean型的么?怎么定义,实现大小写区分查询
Elasticsearch | 作者 artomu | 发布于2016年11月11日 | 阅读数:10885
这是我的mapping设置:
"template_srclog": {
"order": 0,
"template": "srclog*",
"settings": {
"index": {
"refresh_interval": "5s",
"store": {
"type": "niofs"
},
"analysis": {
"analyzer": {
"default": {
"type": "ik"
}
}
},
"number_of_shards": "6",
"number_of_replicas": "0"
}
},
"mappings": {
"srclog_type": {
"_ttl": {
"default": "7d",
"enabled": false
},
"_source": {
"enabled": true
},
"dynamic_templates": [
{
"millis-to-long": {
"mapping": {
"index": "not_analyzed",
"type": "long"
},
"match_mapping_type": "string",
"match": "*Millis"
}
},
{
"lineNumber-to-long": {
"mapping": {
"index": "not_analyzed",
"type": "long"
},
"match_mapping_type": "string",
"match": "lineNumber"
}
},
{
"sting-to-long": {
"mapping": {
"index": "not_analyzed",
"type": "long"
},
"match_mapping_type": "string",
"match": "*_long"
}
},
{
"sting-to-double": {
"mapping": {
"index": "not_analyzed",
"type": "double"
},
"match_mapping_type": "string",
"match": "*_double"
}
},
{
"sting-to-boolean": {
"mapping": {
"index": "not_analyzed",
"type": "boolean"
},
"match_mapping_type": "string",
"match": "*_boolean"
}
},
{
"lineContent": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match": "*lineContent"
}
},
{
"default-fields": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string"
}
}
],
"_all": {
"enabled": true
}
}
},
"aliases": {}
}
}
"template_srclog": {
"order": 0,
"template": "srclog*",
"settings": {
"index": {
"refresh_interval": "5s",
"store": {
"type": "niofs"
},
"analysis": {
"analyzer": {
"default": {
"type": "ik"
}
}
},
"number_of_shards": "6",
"number_of_replicas": "0"
}
},
"mappings": {
"srclog_type": {
"_ttl": {
"default": "7d",
"enabled": false
},
"_source": {
"enabled": true
},
"dynamic_templates": [
{
"millis-to-long": {
"mapping": {
"index": "not_analyzed",
"type": "long"
},
"match_mapping_type": "string",
"match": "*Millis"
}
},
{
"lineNumber-to-long": {
"mapping": {
"index": "not_analyzed",
"type": "long"
},
"match_mapping_type": "string",
"match": "lineNumber"
}
},
{
"sting-to-long": {
"mapping": {
"index": "not_analyzed",
"type": "long"
},
"match_mapping_type": "string",
"match": "*_long"
}
},
{
"sting-to-double": {
"mapping": {
"index": "not_analyzed",
"type": "double"
},
"match_mapping_type": "string",
"match": "*_double"
}
},
{
"sting-to-boolean": {
"mapping": {
"index": "not_analyzed",
"type": "boolean"
},
"match_mapping_type": "string",
"match": "*_boolean"
}
},
{
"lineContent": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match": "*lineContent"
}
},
{
"default-fields": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string"
}
}
],
"_all": {
"enabled": true
}
}
},
"aliases": {}
}
}
2 个回复
artomu - 90后IT男
赞同来自:
PUT /mytest
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"type": "custom",
"tokenizer": "ik",
"filter": "uppercase"
}}
}
}}
PUT /mytest/_mapping/my_type
{
"properties": {
"capital": {
"type": "string",
"analyzer": "my_analyzer"
}
}
}
CODER_LIU - 90后coder
赞同来自: