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

时间:2017-04-12 11:04:33

标签: 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.找到在计算机上得分超过50分的学生名单。

     

2.查找在两个科目中得分超过60分的学生名单。

1 个答案:

答案 0 :(得分:1)

使用范围查询: -

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

选中此link