# Unable to match by value in array field

**URL:** <https://discuss.elastic.co/t/unable-to-match-by-value-in-array-field/139607>\
**Category:** Elasticsearch\
**Created:** [July 11, 2018, 3:12pm UTC](https://discuss.elastic.co/t/unable-to-match-by-value-in-array-field/139607 "2018-07-11T15:12:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cweinberger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cweinberger/32/33147_2.png) [@cweinberger](https://discuss.elastic.co/u/cweinberger)\
**Post date:** [July 11, 2018, 3:12pm UTC](https://discuss.elastic.co/t/unable-to-match-by-value-in-array-field/139607/1 "2018-07-11T15:12:39Z")

</div>

Hello,

I have a field where I store an array of strings (categories). When querying the categories I only receive a result when I'm searching for the first element of the categories' array (in my example below: `hello`).

**When searching for any other element than the first one I won't receive any results.**

I have a field named `categories` that is mapped like this:

**PUT /products/\_mapping/\_doc**

```auto
...
"categories": {
      "type": "text"
    },
...

```

My document has an array of categories:

**PUT /products/\_doc/42**

```auto
{
    "_index": "products",
    "_type": "_doc",
    "_id": "42",
    "_version": 1,
    "found": true,
    "_source": {
        ...
        "categories": [
            "hello",
            "world"
        ],
        ...
    }
}

```

This is the search query:  
**POST /products/\_search**

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "categories": {
              "query": "hello",
              "boost": 100
            }
          }
        }
      ]
    }
  }
}

```

> one result (product with `id 42`)

This one produces no results:  
**POST /products/\_search**

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "categories": {
              "query": "world",
              "boost": 100
            }
          }
        }
      ]
    }
  }
}

```

> no result

I'm on Elastic Search 6.3.

Any ideas?

Thanks,  
Christian

---

<div class="post-metadata">

**Author:** ![cweinberger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cweinberger/32/33147_2.png) [@cweinberger](https://discuss.elastic.co/u/cweinberger)\
**Post date:** [July 12, 2018, 2:10pm UTC](https://discuss.elastic.co/t/unable-to-match-by-value-in-array-field/139607/2 "2018-07-12T14:10:19Z")

</div>

Ok, it seems to work. Probably I had a problem in my data fields with the last import!

---

<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:** [August 9, 2018, 2:10pm UTC](https://discuss.elastic.co/t/unable-to-match-by-value-in-array-field/139607/3 "2018-08-09T14:10:37Z")

</div>

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