elasticsearch - 排序子句中的非索引字段

标签 elasticsearch

我的 flex 搜索索引映射中有一个字段,该字段不会用于任何搜索。但我在查询的sort子句中要求它。是否可以在映射定义中放入“index”:“false”?

基本上在映射中:

"name":{
  "type": "keyword",
   "index": "false"
}

并在查询中:
 "sort" : [
      {"name" : {"order" : "asc"}}
   ]

最佳答案

请从Elasticsearch官方文档中阅读有关index选项的信息,该选项中指出:

The index option controls whether field values are indexed. It accepts true or false and defaults to true. Fields that are not indexed are not queryable.



因此,在您的情况下,您明确将其设置为false,因此您将无法在查询中包括它,因此排序查询也不适用于此字段。

通过在索引中创建一个这样的字段,然后查看是否允许您对该字段进行排序,您可以轻松地自己验证这一点。

关于elasticsearch - 排序子句中的非索引字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57320727/

相关文章:

java - Elasticsearch:从点击中学习(搜索结果排名)

elasticsearch - 如何计算嵌套字段内的字段数? -Elasticsearch

elasticsearch - 多个Elasticsearch匹配查询

spring - org.springframework.beans.factory.BeanCreationException:创建名称为'elasticConfiguration的bean时出错

elasticsearch - 使用弹性聚合(NEST)时为null_pointer_exception

elasticsearch - 如何构建计算 "new"属性的日期直方图查询

elasticsearch - Shell和Cron之间的馆长版本差异

ruby-on-rails - 如何构建任务 'elasticsearch:import:model'

hadoop - 是否有用于 Elasticsearch 的 Apache Drill 存储插件?

elasticsearch - ElasticSearch是否适合检索大量搜索记录?