我有一个带有以下映射的类型
PUT /testindex
{
"mappings" : {
"products" : {
"properties" : {
"category_name" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想搜索一个确切的单词.这就是为什么我把它设置为not_analyzed.但问题是我想用小写或大写搜索[不区分大小写].
我搜索它并找到了一种设置不区分大小写的方法.
curl -XPOST localhost:9200/testindex -d '{
"mappings" : {
"products" : {
"properties" : {
"category_name":{"type": "string", "index": "analyzed", "analyzer":"lowercase_keyword"}
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
有没有办法将这两个映射到同一个字段.
谢谢..
Joh*_*one 38
我认为这个例子符合您的需求:
$ 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"
}
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
取自此处:如何在elasticsearch中设置tokenizer
它在字符串字段上使用关键字tokenizer和小写过滤器,我相信它可以满足您的需求.
| 归档时间: |
|
| 查看次数: |
23599 次 |
| 最近记录: |