本文介绍了弹性搜索地图对not_analyzed文档不敏感的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有以下映射的类型
I have a type with following mapping
PUT /testindex
{
"mappings" : {
"products" : {
"properties" : {
"category_name" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}
我想搜索一个确切的单词。这是为什么我设置为not_analyzed。
但问题是我想搜索小写或大写字母[不区分大小写]。
I wanted to search for an exact word.Thats why i set this as not_analyzed.But the problem is i want to search that with lower case or upper case[case insensitive].
我搜索它,并找到一种方式来设置案例
I searched for it and found a way to set case insensitive.
curl -XPOST localhost:9200/testindex -d '{
"mappings" : {
"products" : {
"properties" : {
"category_name":{"type": "string", "index": "analyzed", "analyzer":"lowercase_keyword"}
}
}
}
}'
是否任何方式做这两个映射到同一个字段?
Is there any way to do these two mappings to same field.?
谢谢..
推荐答案
我想这个例子满足你的需要:
I think this example meets your needs:
$ curl -XPUT localhost:9200/testindex/ -d '
{
"settings":{
"index":{
"analysis":{
"analyzer":{
"analyzer_keyword":{
"tokenizer":"keyword",
"filter":"lowercase"
}
}
}
}
},
"mappings":{
"test":{
"properties":{
"title":{
"analyzer":"analyzer_keyword",
"type":"string"
}
}
}
}
}'
从这里取得:
它使用关键字标记器和字符串字段上的小写过滤器,我相信你会想要的。
it uses both the keyword tokenizer and the lowercase filter on a string field which I believe does what you want.
这篇关于弹性搜索地图对not_analyzed文档不敏感的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!