不为失败找理由,要为成功找方法。

term:{"field":123}和term:{"field":"123"}在查询时的区别

Elasticsearch | 作者 ridethewind | 发布于2019年03月26日 | 阅读数:1031

term:{"field":123}和term:{"field":"123"}在查询时的区别是什么啊?第二个会转成数字么?
已邀请:

bellengao - 博客: https://www.jianshu.com/u/e0088e3e2127

赞同来自:

取决于field本身是什么类型,会把查询词转换成对应的类型,当然,转换失败会报错

hapjin

赞同来自:

 The term query looks for the exact term in the field’s inverted index — it doesn’t know anything about the field’s analyzer. 
term查询没有Analyze过程,所以不管filed是不是text类型,没有什么区别。
 
数字貌似在Lucene底层也是 textual tokens。


Surprisingly, this approach also indexed numbers as if they were textual tokens (the inverted index), but it did so at multiple precision levels for each indexed number, so that entire ranges of numbers were indexed as a single token. 

要回复问题请先登录注册