2014-09-15
这个日期,但是看看下面的查询结果中的总数量:_all
搜索全年就会返回所有推文,而使用字段date
搜索年份却没有结果呢?为什么使用两者所得到的结果是不同的?_all
和date
在索引时没有被相同处理。我们来看看Elasticsearch是如何处理我们的文档结构的。我们可以对gb
的tweet
使用mapping请求:date
字段被识别成了date
类型。_all
没有出现是因为他是默认字段,但是我们知道字段_all
实际上是string
类型的。date
的字段和类型为string
的字段的索引方式是不同的。date
and fields of type string
are indexed differently, and can thus be searched differently. That's not entirely surprising. You might expect that each of the core data types -- strings, numbers, booleans and dates -- might be indexed slightly differently. And this is true: there are slight differences.string
fields) and fields that represent full text. This distinction is really important -- it's the thing that separates a search engine from all other databases.