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


(Pierre De Soyres) #1

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.


(David Pilato) #2

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.


(Pierre De Soyres) #3

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"
         }
        }
      }
    }
  }

(Colin Goodheart-Smithe) #4

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


(Pierre De Soyres) #5

OOooh yes, you're right. Thank you !


(system) #6

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