# Running a Match across Array and treating each row exclusively

**URL:** <https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096>\
**Category:** Elasticsearch\
**Created:** [March 8, 2022, 1:58pm UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096 "2022-03-08T13:58:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![snoopy20](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@snoopy20](https://discuss.elastic.co/u/snoopy20)\
**Post date:** [March 8, 2022, 1:58pm UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096/1 "2022-03-08T13:58:51Z")

</div>

Hi,

I had several keys on an object (such as .name1, .name2) and was using dis\_max along with match to run independent and identical queries and return the one with the highest score. Now the data has changed to an Array and I can see that Match is working across the items which produces a different score.

Old method (should just one query)

```auto
            should.push({
              dis_max: {
                queries: [
                  {
                    match: {
                      nameA: { _name:'nameA', query, ...req.address.params }
                    }
                  }
                ]
              }

```

So now the requirement is

[  
'Andrew Smith Jones',  
'Andrew Burke'  
]

If I search for 'Smith Jones Burke' the score would be higher, the second row should have no impact as the first row is a higher match.

Thoughts?

---

<div class="post-metadata">

**Author:** ![sagarpatel](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@sagarpatel](https://discuss.elastic.co/u/sagarpatel)\
**Post date:** [March 9, 2022, 6:59am UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096/2 "2022-03-09T06:59:44Z")

</div>

> [@snoopy20](#):
>
> If I search for 'Smith Jones Burke' the score would be higher, the second row should have no impact as the first row is a higher match.

what do you mean by second row ? do you mean to order array value when you get response ?

Please add more details like sample document and expected result.

---

<div class="post-metadata">

**Author:** ![snoopy20](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@snoopy20](https://discuss.elastic.co/u/snoopy20)\
**Post date:** [March 9, 2022, 9:38am UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096/3 "2022-03-09T09:38:18Z")

</div>

[  
'Andrew Smith Jones',  
'Andrew Burke'  
]

Let's say each word is worth one point and I search 'Smith Jones Burke'

I would like the score to be 2, not 3.

(which is how it was when I used dis\_max in conjunction with multiple queries)

---

<div class="post-metadata">

**Author:** ![snoopy20](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@snoopy20](https://discuss.elastic.co/u/snoopy20)\
**Post date:** [March 11, 2022, 3:51pm UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096/4 "2022-03-11T15:51:47Z")

</div>

bump ^^ 🙂

---

<div class="post-metadata">

**Author:** ![snoopy20](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@snoopy20](https://discuss.elastic.co/u/snoopy20)\
**Post date:** [March 17, 2022, 4:59pm UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096/5 "2022-03-17T16:59:07Z")

</div>

Bumpty bump, almost like I'm desperate. 😉

Got to be some means to do this...

---

<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:** [April 14, 2022, 4:59pm UTC](https://discuss.elastic.co/t/running-a-match-across-array-and-treating-each-row-exclusively/299096/6 "2022-04-14T16:59:18Z")

</div>

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