我希望能够在用户提供的特定日期范围内获取文档并显示要查看的文档。我当前构建的查询如下所示: 的查询
public class A extends AppCompatActivity{
...
public void setText(String text){
textView.setText(text);
}
}
public class B extends AppCompatActivity{
...
Button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
A a = new A();
a.setText(editText.getText().toString());
finish();
}
});
}
我想要获取的json文档的时间部分如下所示:
JSON
{
"aggs": {
"range": {
"date_range": {
"field": "metadata.o2r.temporal.begin",
"ranges": [
{ "from": "2017-03-30T12:35:41.142Z", "to": "2017-08-02T22:00:00.000Z", "key": "quarter_01" }
],
"keyed": true
}
}
}
}
'
目前我可以查询"开始"或者"结束"但我希望能够以这样的方式修改查询:开始成为"来自" 结束成为"到"的值。这里的问题是我不希望修改原始的JSON。
更新了查询
"temporal": {
"begin": "2017-08-01T22:00:00.000Z",
"end": "2017-03-30T12:35:41.142Z"
},
响应
curl -XGET 'localhost:9201/test/_search?size=0&pretty' -H 'Content-Type: application/json' -d'
> {
> "query": {
> "bool": {
> "must": [
> {
> "range": {
> "metadata.o2r.temporal.begin": {
> "from": "2016-01-01T12:35:41.142Z"
> }
> }
> } ,
> {
> "range": {
> "metadata.o2r.temporal.end": {
> "to": "2016-12-30T22:00:00.000Z"
> }
> }
> }
> ]
> }
> }
> }
> '
答案 0 :(得分:1)
这可能对您有所帮助
{
"query": {
"bool": {
"must": [
{
"range": {
"metadata.o2r.temporal.begin": {
"from": "2017-03-30T12:35:41.142Z"
}
}
} ,
{
"range": {
"metadata.o2r.temporal.end": {
"to": "2017-08-02T22:00:00.000Z"
}
}
}
]
}
}
}