我正在尝试使用带有弹性搜索的范围查询
{
query:{
范围:{
order_no:{
gte:VM-0001,
lte:VM-0005
}
}
}
}
但是弹性返回没有结果。我发现系统有字符串的问题包括 -
或 _
这是该字段的映射:
order_no:{
type:string
index_analyzer:str_index_analyzer,
search_analyzer:str_search_analyzer
}
{
分析:{
analyzer:{
str_search_analyzer:{
tokenizer:keyword,
filter:[
smallcase
]
},
str_index_analyzer :{
tokenizer:keyword,
filter:[
smallcase,
substring
]
}
},
filter:{
substring:{
type:nGram,
min_gram:1,
max_gram:20
}
}
}
}
{
query:{
range:{
order_no:{
gte vm-0001,
lte:vm-0005
}
}
}
}
I am trying use range query with elasticsearch
{
"query": {
"range": {
"order_no": {
"gte": "VM-0001",
"lte": "VM-0005"
}
}
}
}
But elastic return no result. I found system have problem with string include -
or _
This is mapping of that field:
"order_no" : {
"type" : "string",
"index_analyzer" : "str_index_analyzer",
"search_analyzer" : "str_search_analyzer"
}
{
"analysis": {
"analyzer": {
"str_search_analyzer": {
"tokenizer": "keyword",
"filter": [
"lowercase"
]
},
"str_index_analyzer": {
"tokenizer": "keyword",
"filter": [
"lowercase",
"substring"
]
}
},
"filter": {
"substring": {
"type": "nGram",
"min_gram": 1,
"max_gram": 20
}
}
}
}
解决方案 {
"query": {
"range": {
"order_no": {
"gte": "vm-0001",
"lte": "vm-0005"
}
}
}
}
这篇关于使用带有弹性搜索字符串的范围查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!