elasticsearch,Nosql,elasticsearch" /> elasticsearch,Nosql,elasticsearch" />

Nosql 空字段文档模型

Nosql 空字段文档模型,nosql,elasticsearch,Nosql,elasticsearch,我一般不熟悉elasticsearch和nosql文档模型 在elasticsearch中,对于空字段的最佳做法是什么 我们应该声明它为空还是完全忽略它 示例:电子邮件字段 [{ id:1, name:"John", email:"userone@erj.com" }, { id:2, name:"David", email:null }, { id:3, name:"Tony" }] 如何处理空字段完全取决于您自己。默认情况下,

我一般不熟悉elasticsearch和nosql文档模型

在elasticsearch中,对于空字段的最佳做法是什么

我们应该声明它为空还是完全忽略它

示例:电子邮件字段

[{
    id:1,
    name:"John",
    email:"userone@erj.com"
},
{
    id:2,
    name:"David",
    email:null
},
{
    id:3,
    name:"Tony"
}]

如何处理空字段完全取决于您自己。默认情况下,ES将完全忽略空字段。如果需要,还可以在映射中为空字段指定文档的默认值

映射示例:

{
    "_default_" : {
        "properties" : {
            "id" : {"type" : "string", "index" : "not_analyzed"},
            "name" : {"type" : "string"},
            "email" : {"type" : "string", "index" : "not_analyzed", "null_value" : "NOEMAILAVAILABLE"}
        }
    }
}
这里概述了处理此问题的潜在方法: