Unable to multi_match in php library

I'm trying to use a filter to search multiple fields and query between dates. The PHP looks like this:

$params = [
            'index' => $this->index . '*',
            'size' => self::HITS_SIZE,
            'from' => $this->calculateOffset($this->currentPage),
            'sort' => "createdAt:$this->sort",
            'body' => [
                'query' => [
                    "bool" => [
                        "filter" => [
                            'multi_match' => [
                                'type' => 'best_fields',
                                'query' => 'bakery.second',
                                'lenient' => true
                            ],
                            'range' => [
                                'createdAt' => [
                                    "format" => "epoch_second",
                                    "gt" => $this->fromTime->getTimestamp(),
                                    "lt" => $this->toTime->getTimestamp(),
                                    "boost" => 2.0
                                ]
                            ]
                        ]
                    ]
                ]
            ]
        ];

        $this->results = $this->client->search($params);

When running the code I get the following error response thrown:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[multi_match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
        "line": 1,
        "col": 105
      }
    ],
    "type": "x_content_parse_exception",
    "reason": "[1:105] [bool] failed to parse field [filter]",
    "caused_by": {
      "type": "parsing_exception",
      "reason": "[multi_match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]",
      "line": 1,
      "col": 105
    }
  },
  "status": 400
}

When I use Kibana I do get results without an error:

GET some-index-*/_search
{
"query": {
    "bool": {
      "filter": [
        {
          "multi_match": {
            "type": "best_fields",
            "query":"bakery.second",
            "lenient": true
          }
        },
        {
          "range": {
            "createdAt": {
              "format": "strict_date_optional_time",
              "gte" : "now-10d",
              "lt" :  "now"
            }
          }
        }
      ]
    }
  }
}

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