# Boolean searching a multi-value multi-field

**URL:** <https://discuss.elastic.co/t/boolean-searching-a-multi-value-multi-field/138359>\
**Category:** Elasticsearch\
**Created:** [July 3, 2018, 11:05am UTC](https://discuss.elastic.co/t/boolean-searching-a-multi-value-multi-field/138359 "2018-07-03T11:05:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkazez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkazez/32/25991_2.png) [@bkazez](https://discuss.elastic.co/u/bkazez)\
**Post date:** [July 3, 2018, 11:05am UTC](https://discuss.elastic.co/t/boolean-searching-a-multi-value-multi-field/138359/1 "2018-07-03T11:05:01Z")

</div>

Hello all, I have some documents that look something like this:

```
{
"dataset_id": 1,
"table_name": "some names",
"columns": ["col1", "col2", "surname"],
"records": [
  {
    "values": ["val1", "", "JOHNSON"],
    "names": ["JOHNSON"]
  },
  {
    "values": ["val1", "", "DELMAN JANSON"],
    "names": ["DELMAN", "JANSON"]
  }        
]
}

```

The `names` field has been analyzed by multiple analyzers (phonetic, edge n-gram, etc.).

How can I construct a query to require, e.g., that `names[x].phonetic` matches AND `names[x].ngram` matches? Right now I can figure out how to match `names.phonetic` AND `names.ngram`, but I can't figure out how to ensure that the `AND` applies to the same element within the list. Hoping I don't have to create a separate nested document for every item in `names`.

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 3, 2018, 11:23am UTC](https://discuss.elastic.co/t/boolean-searching-a-multi-value-multi-field/138359/2 "2018-07-03T11:23:52Z")

</div>

Yes you need to use a nested data type for this.  
Or you can denormalize your data and index only the element of the array as a single document.

---

<div class="post-metadata">

**Author:** ![bkazez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkazez/32/25991_2.png) [@bkazez](https://discuss.elastic.co/u/bkazez)\
**Post date:** [July 3, 2018, 11:57am UTC](https://discuss.elastic.co/t/boolean-searching-a-multi-value-multi-field/138359/3 "2018-07-03T11:57:06Z")

</div>

OK, thank you for the quick reply!

---

<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 31, 2018, 11:57am UTC](https://discuss.elastic.co/t/boolean-searching-a-multi-value-multi-field/138359/4 "2018-07-31T11:57:15Z")

</div>

Closed on July 31, 2018, 11:57am UTC

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