# Setting Up Params for Multiple Match: Array Problem

**URL:** <https://discuss.elastic.co/t/setting-up-params-for-multiple-match-array-problem/34359>\
**Category:** Elasticsearch\
**Created:** [November 11, 2015, 10:59pm UTC](https://discuss.elastic.co/t/setting-up-params-for-multiple-match-array-problem/34359 "2015-11-11T22:59:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jevchance](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jevchance/32/5853_2.png) [@jevchance](https://discuss.elastic.co/u/jevchance)\
**Post date:** [November 11, 2015, 10:59pm UTC](https://discuss.elastic.co/t/setting-up-params-for-multiple-match-array-problem/34359/1 "2015-11-11T22:59:32Z")

</div>

Hey, I'm having a newbie problem for sure.

I'm looking to do a direct match on multiple keywords using boost to adjust relevance. I'm using the PHP client for this. I'm having difficulty rectifying the fact that I have multiple array indices with the same name.

```
$params = [
'index' => 'people',
'type' => 'person',
'body' => [
    'query' => [
        'bool' => [
            'should' => [
                'match' => [
                    'Company1' => [
                        'query' => $order['BillTo_Name'],
                        'boost' => $_GET['company-name-weight']
                    ]
                ],
                'match' => [
                    'Address1' => [
                        'query' => $order['ShipTo_Addr1'],
                        'boost' => $_GET['address-weight']
                    ]
                ],
                'match' => [
                    'PostalCode' => [
                        'query' => $order['ShipTo_Zip'],
                        'boost' => $_GET['company-name-weight']
                    ]
                ],
                'match' => [
                    'LastName' => [
                        'query' => $order['contact'],
                        'boost' => $_GET['name-weight']
                    ]
                ]
            ]
        ]
    ]
]
];

```

This causes my array to collapse down to a single matching criteria, because I have 4 rows with the same array index.

```
var_dump($params);

array(3) {
  ["index"]=>
  string(5) "leads"
  ["type"]=>
  string(4) "lead"
  ["body"]=>
  array(1) {
    ["query"]=>
    array(1) {
      ["bool"]=>
      array(1) {
        ["should"]=>
        array(1) {
          ["match"]=>
          array(1) {
            ["LastName"]=>
            array(2) {
              ["query"]=>
              string(10) "Parker"
              ["boost"]=>
              string(1) "1"
        }
          }
        }
      }
    }
  }
}

```

I'm at a loss how to restructure this query with 4 separate matches, specifying boost for each, in a way that the PHP client can digest.

---

<div class="post-metadata">

**Author:** ![jevchance](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jevchance/32/5853_2.png) [@jevchance](https://discuss.elastic.co/u/jevchance)\
**Post date:** [November 12, 2015, 6:41pm UTC](https://discuss.elastic.co/t/setting-up-params-for-multiple-match-array-problem/34359/2 "2015-11-12T18:41:20Z")

</div>

Answered my own question, leaving here for posterity. You need to nest each match clause 1 array deeper.

```
$params = [
'index' => 'leads',
'type' => 'lead',
'body' => [
    'query' => [
        'bool' => [
            'should' => [
            [
                'match' => [
                    'Company1' => [
                        'query' => $order['BillTo_Name'],
                        'boost' => $_GET['company-name-weight']
                    ]
                ]
            ],[
                'match' => [
                    'Address1' => [
                        'query' => $order['ShipTo_Addr1'],
                        'boost' => $_GET['address-weight']
                    ]
                ]
            ],[
                'match' => [
                    'PostalCode' => [
                        'query' => $order['ShipTo_Zip'],
                        'boost' => $_GET['company-name-weight']
                    ]
                ]
            ],[
                'match' => [
                    'LastName' => [
                        'query' => $order['contact'],
                        'boost' => $_GET['name-weight']
                    ]
                ]
            ]
            ]
        ]
    ]
]
];
```

---

<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 5, 2017, 11:38pm UTC](https://discuss.elastic.co/t/setting-up-params-for-multiple-match-array-problem/34359/3 "2017-07-05T23:38:52Z")

</div>


