elasticsearch 在elasticsearch中查找小数点为零的数字
我用十进制零显示数字,如下所示:25785-->25'785.00 我想复制并粘贴搜索字段中显示的号码,并找到我的实际号码。 当我这样做时,我的查询看起来像这样
elasticsearch 在elasticsearch中查找小数点为零的数字,
elasticsearch,
elasticsearch,我用十进制零显示数字,如下所示:25785-->25'785.00 我想复制并粘贴搜索字段中显示的号码,并找到我的实际号码。 当我这样做时,我的查询看起来像这样“query:”(25785.00或25785.00*)“,但索引编号是25785,并且找不到它 我可以用不同的方法索引这个字段,这样它也可以找到带小数点零的数字吗 映射: "my-money" : { "type" : "text",
“query:”(25785.00或25785.00*)“
,但索引编号是25785
,并且找不到它
我可以用不同的方法索引这个字段,这样它也可以找到带小数点零的数字吗
映射:
"my-money" : {
"type" : "text",
"fields" : {
"raw" : {
"type" : "double"
}
}
},
您可以使用
matchphrase
查询。详情见
映射:
PUT /mstest
{
"mappings": {
"test": {
"properties": {
"money": {
"type": "text",
"fields": {
"raw": {
"type": "double"
}
}
}
}
}
}
}
现有数据:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "mstest",
"_type": "test",
"_id": "AXlhj0RUNamWTgl090_3",
"_score": 1,
"_source": {
"money": 257851111
}
},
{
"_index": "mstest",
"_type": "test",
"_id": "AXlhjR3f7ALnT2aUN_qN",
"_score": 1,
"_source": {
"money": 25785
}
}
]
}
}
搜索查询号码“25785”:
GET mstest/test/_search
{
"query": {
"match_phrase": {
"money.raw": "25785.00"
}
}
}
输出:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "mstest",
"_type": "test",
"_id": "AXlhjR3f7ALnT2aUN_qN",
"_score": 1,
"_source": {
"money": 25785
}
}
]
}
}
看看这是否能帮你解除障碍