# Unable to multi\_match in php library

**URL:** <https://discuss.elastic.co/t/unable-to-multi-match-in-php-library/308107>\
**Category:** Elasticsearch\
**Created:** [June 24, 2022, 11:32am UTC](https://discuss.elastic.co/t/unable-to-multi-match-in-php-library/308107 "2022-06-24T11:32:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeroen2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeroen2/32/55694_2.png) [@Jeroen2](https://discuss.elastic.co/u/Jeroen2)\
**Post date:** [June 24, 2022, 11:32am UTC](https://discuss.elastic.co/t/unable-to-multi-match-in-php-library/308107/1 "2022-06-24T11:32:07Z")

</div>

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

```auto
$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:

```auto
{
  "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:

```auto
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"
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 22, 2022, 11:32am UTC](https://discuss.elastic.co/t/unable-to-multi-match-in-php-library/308107/2 "2022-07-22T11:32:36Z")

</div>

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