作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此处供引用的是代码。我正在尝试制作一个记录到 elasticsearch 的 hubot 插件,然后使用 hubot 命令搜索这些日志。
https://gist.github.com/4050748
我正在尝试检索匹配两个查询的记录。
{
query: {
match: {
user: "SomeUsername"
},
range: {
date: {
from: (Date.now() - 3600)
}
}
},
size: 50
}
我期待:
我得到了:
如何获取过去一小时内某个用户名的所有记录?我需要将 match_all 与过滤器一起使用吗?我正在尝试的是不受支持的吗?
在 SQL 中它会是这样的:
Select (*) from messages where user_name = ? and time > ?
最佳答案
对于任何偶然发现这个问题并想知道在 ElasticSearch 中结合匹配和范围查询是什么样子的人,这个例子看起来像
curl 'localhost:9200/<index>/_search?pretty=true' -d '{
"query" : {
"bool": {
"must": [
{
"match": {
"user": "SomeUsername"
}
},
{
"range" : {
"date": {
"gt": "now-1h"
}
}
}
]
}
}
}'
关于coffeescript - 如何在 ElasticSearch 中组合多个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13352146/
我是一名优秀的程序员,十分优秀!