Help with this query (combine term and range)

When I run this query with range I get results:

    {
       "query":{
          "range":{
             "crawled":{
                "lt":1591666432
             }
          },
       },
       "from":0,
       "size":1
    }

When I run this query with term I get results:

    {
       "query":{
          "term":{
             "status":{
                "value":1
             }
          }
       },
       "from":0,
       "size":1
    }

But when I run this query (combining range and term) I get an error message:

    {
       "query":{
          "range":{
             "crawled":{
                "lt":1591666432
             }
          },
          "term":{
             "status":{
                "value":1
             }
          }
       },
       "from":0,
       "size":1
    }

This is the error message:

    [range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]

you can combine term and range with Bool query:

   {
      "query": {
        "bool": {
          "must": [
            {
              "range": {
                "crawled": {
                  "lt": 1591666432
                }
              }
            },
            {
              "term": {
                "status": {
                  "value": 1
                }
              }
            }
          ]
        },
        "from": 0,
        "size": 1
      }
    }
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.