gpt4 book ai didi

elasticsearch - 在ElasticSearch中在索引时将值映射为 bool 值

转载 作者:行者123 更新时间:2023-12-02 23:35:47 24 4
gpt4 key购买 nike

我得到带有2个值为"is"或“否”的字符串字段的JSON对象。

是否可以定义将"is"映射为“true”,将“否”映射为“false”的映射?

如果值不是yes / no而是另外两个字符串,例如“yep”和“nope”,该怎么办?

最佳答案

是,对于documentation中的OP用例:

The boolean type also supports passing the value as a number or a string (in this case 0, an empty string, false, off and no are false, all other values are true).



因此,“ no ”将映射为false,而“ yes ”将映射为true,只需在映射中将字段指定为“boolean”类型即可。

关于elasticsearch - 在ElasticSearch中在索引时将值映射为 bool 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31275278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com