【发布时间】:2021-03-08 17:32:16
【问题描述】:
我有带有价格字段的json 文档,而且这个价格本质上是不同的。
如果我不想按此字段搜索,我是否可以或应该贬低创建反向索引。而且我认为在使用弹性搜索时将这些唯一字段存储在索引中并不好。
【问题讨论】:
标签: elasticsearch
我有带有价格字段的json 文档,而且这个价格本质上是不同的。
如果我不想按此字段搜索,我是否可以或应该贬低创建反向索引。而且我认为在使用弹性搜索时将这些唯一字段存储在索引中并不好。
【问题讨论】:
标签: elasticsearch
如果你愿意,你可以disable the indexing某些字段
PUT test_lalilulelo_1986
{
"mappings": {
"properties": {
"price": {
"enabled": "false"
}
}
}
}
提取文档
POST test_lalilulelo_1986/_doc
{
"price": 100
}
查询
POST test_lalilulelo_1986/_search
返回文档
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "test_lalilulelo_1986",
"_type" : "_doc",
"_id" : "x2wsEXgBLiMtJ3pUffYA",
"_score" : 1.0,
"_source" : {
"price" : 100
}
}
]
}
}
这个即使价格大于10也不返回文件
POST test_lalilulelo_1986/_search
{
"query": {
"range": {
"price": {
"gte": 10
}
}
}
}
没有结果
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
该值仍然可以从_source 字段中检索到,但它不可搜索或以任何其他方式存储
【讨论】: