elasticsearch - Elasticsearch自定义查询以获取特定范围的元素?

标签 elasticsearch spring-data-elasticsearch

我是Elasticsearch的新手,所以这是我的疑问:
I have large data inserted into Elastic search. The data that I have inserted contains an attribute of marks of each subject, is it possible to write an Elasticsearch query to find the number of students who has their marks in the inputted range.
示例:

|studentname | maths | computers |
++++++++++++++++++++++++++++++++++
|s1          |78     |90         |
==================================
|s2          |56     |75         |
==================================
|s3          |45     |50         |
==================================

假设以表格形式显示在ES中的数据,则有可能

1.Find the list of students who has scored more than 50 marks in computers.

2.Find the list of students who has scored more than 60 marks in both subjects.

最佳答案

使用范围查询:

{  
   "query":{"bool":{"must":{"range":{computers:{gte: 50} }}}}
}

检查此link

关于elasticsearch - Elasticsearch自定义查询以获取特定范围的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43367788/

相关文章:

elasticsearch - 如何为elasticsearch的repository-hdfs插件配置elasticserch.yml

elasticsearch - Elasticsearch停用词的相对路径

java - 使用自定义 @Query 注释的 Spring-Data Elasticsearch 存储库计数不起作用 "Expected 1 but found 30 results"

java - Spring Boot 应用程序中的 Spring Data Elasticsearch

c# - 在Nest 7中添加附件管道

c# - 使用NEST搜索elasticsearch中的所有类型和所有索引

elasticsearch - 如何更新 Elasticsearch 中的映射以更改字段数据类型并更改字符串中的分析器类型

spring-boot - ElasticSearch - Spring Boot - Upsert 抛出 DocumentMissingException

java - Elasticsearch 使用 java api 返回原始 json

java - 如何使用 spring-data-elasticsearch 在 elasticsearch 中进行集成测试?