Getting "parser not found" error on a filter date range aggregation

I have the following mapping :

{
  "my_index": {
    "mappings": {
      "my_type": {
        "properties": {
          "date": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis||dd/MM/yyyy HH:mm"
          }
         "data": {
           "type": "keyword"
         }
        }
      }
    }
  }
}

And I post the following query :

{
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        }
      ]
    }
  },
  "aggs": {
    "filter": {
      "range": {
        "date": {
          "gte": 1476108600401,
          "lte": 1507644600401,
          "format": "epoch_millis"
        }
      }
    },
    "aggs": {
      "value": {
        "terms": {
          "field": "value",
          "size": 10
        }
      }
    }
  }
}

And I get the following error;

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "[range] unknown field [date], parser not found"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "[range] unknown field [date], parser not found"
  },
  "status": 400
}

Note that when removing the range query and move it to the query part, everything works fine :

{
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        },
        {
          "range": {
            "date": {
              "gte": 1476108600401,
              "lte": 1507644600401,
              "format": "epoch_millis"
            }
          }
        }
      ]
    }
  }
}

Is there something I missed ?

I'm using elasticsearch 5.5.0

Pierre.

The mapping is wrong. You edited it manually while posting.

Could you provide a full recreation script as described in

It will help to better understand what you are doing.
Please, try to keep the example as simple as possible.

Sorry, you're right here is the index creation :

PUT my_idx
{
    "mappings": {
      "my_type": {
        "properties": {
          "date": {
            "type": "date",
            "format": "strict_date_optional_time||epoch_millis||dd/MM/yyyy HH:mm"
          },
         "data": {
           "type": "keyword"
         }
        }
      }
    }
  }

It looks like you are missing the object for the name of your aggregation inside the aggs object. I think it should instead be:

"aggs": {
  "my_filter_agg": {
    "filter": {
      "range": {
        "date": {
          "gte": 1476108600401,
          "lte": 1507644600401,
          "format": "epoch_millis"
        }
      }
    },
    "aggs": {
      "value": {
        "terms": {
          "field": "value",
          "size": 10
        }
      }
    }
  }
}

The error message is stating that it doesn't know about the field "date" in the JSON for the range aggregation because its interpreted the name of the aggregation as filter and the type of aggregation as range so its trying to map the date to a parameter for the range aggregation which doesn't exist

OOooh yes, you're right. Thank you !

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