Skip to content

range query instead of gte, it uses include_lower, upper, to #196

@sundarv85

Description

@sundarv85

Hello,

When I use the code

    dateFilter := NewBoolQuery()
    dateFilter = dateFilter.Filter(NewRangeQuery("ts").Gte("now-24h/d"))
    dateFilter = dateFilter.Filter(NewRangeQuery("ts").Gte("now-24h"))

I was only expecting the gte keyword to be used. But I see

                         "from": "now-24h/d",
                        "include_lower": true,
                        "include_upper": true,
                        "to": null 

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html also explains only about gte. Is there a reason why you convert to these values. Also, I was trying to find in ES Reference of range query. Is this mentioned somewhere in docs.

Full Query below:

{
  "bool": {
    "_name": "Test",
    "filter": {
      "bool": {
        "filter": [
          {
            "term": {
              "singer": "Michael"
            }
          },
          {
            "term": {
              "kind": "rock"
            }
          }
        ]
      }
    },
    "must": {
      "has_child": {
        "inner_hits": {
          "fields": "ts",
          "name": "ts",
          "size": 1,
          "sort": [
            {
              "ts": {
                "order": "desc"
              }
            }
          ]
        },
        "query": {
          "bool": {
            "filter": {
              "bool": {
                "filter": [
                  {
                    "range": {
                      "ts": {
                        "from": "now-24h/d",
                        "include_lower": true,
                        "include_upper": true,
                        "to": null
                      }
                    }
                  },
                  {
                    "range": {
                      "ts": {
                        "from": "now-24h",
                        "include_lower": true,
                        "include_upper": true,
                        "to": null
                      }
                    }
                  }
                ]
              }
            },
            "must": {
              "match_all": {}
            }
          }
        },
        "score_type": "sum",
        "type": "music"
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions