All days in 2012:
date:[2012/01/01 TO 2012/12/31]
Numbers 1..5
count:[1 TO 5]
Tags between alpha and omega, excluding alpha and omega:
tag:{alpha TO omega}
Numbers from 10 upwards
count:[10 TO *]
Dates before 2012
date:{* TO 2012/01/01}
Curly and square brackets can be combined:
Numbers from 1 up to but not including 5
count:[1..5}
Ranges with one side unbounded can use the following syntax:
age:>10
age:>=10
age:<10
age:<=10
Note
To combine an upper and lower bound with the simplified syntax, you would need to join two clauses with an AND operator:
age:(>=10 AND < 20)
age:(+>=10 +<20)
The parsing of ranges in query strings can be complex and error prone. It is much more reliable to use an explicit range filter.
字符串 URI搜索 Search URI Search Request Body Search Search Shards API Search Template Facets Aggregations Suggesters Context Suggesters Multi Search API Count API Reply API Explain API Percolator More Like This API Benchmark 通过提供请求参数,可以纯粹使用URI来执行搜索请求。使用此模式执行搜索时,并不是所有搜索选项都会暴露,但它可以方便地进行快速“curl测试”。下面是一个示例:
很高兴知道对于range date searches,您必须使用引号,否则年份可以被解释为时间戳: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#numeric-date 如果没有指定日期格式,并且范围查询的目标是日期字段,则会解释表示自纪元以来的毫秒的数值。如果希望值表示年份,例如2020,则需要将其作为String值(例如“2020”)传递,该值将根据默认格式或设置格式进行解析。
3条答案
按热度按时间wgmfuz8q1#
您将需要使用查询字符串搜索(https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html)范围与URI搜索(https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html)相结合
范围
可以为日期、数字或字符串字段指定范围。包含范围用方括号[min TO max]指定,排除范围用花括号{min TO max}指定。
字符串
URI搜索
Search URI Search Request Body Search Search Shards API Search Template Facets Aggregations Suggesters Context Suggesters Multi Search API Count API Reply API Explain API Percolator More Like This API Benchmark
通过提供请求参数,可以纯粹使用URI来执行搜索请求。使用此模式执行搜索时,并不是所有搜索选项都会暴露,但它可以方便地进行快速“curl测试”。下面是一个示例:
型
u1ehiz5o2#
我认为你想查询小于等于100的文档。
字符串
PHP API客户端
型
更多查询..参考
您要求的查询格式..!
型
希望能帮到你!
hmae6n7t3#
扩展BlackPOP的答案
很高兴知道对于
range date searches
,您必须使用引号,否则年份可以被解释为时间戳:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#numeric-date
如果没有指定日期格式,并且范围查询的目标是日期字段,则会解释表示自纪元以来的毫秒的数值。如果希望值表示年份,例如2020,则需要将其作为String值(例如“2020”)传递,该值将根据默认格式或设置格式进行解析。
示例
字符串