# Match query returns different number of partial results each time it is run

**URL:** <https://discuss.elastic.co/t/match-query-returns-different-number-of-partial-results-each-time-it-is-run/58183>\
**Category:** Elasticsearch\
**Created:** [August 16, 2016, 8:10pm UTC](https://discuss.elastic.co/t/match-query-returns-different-number-of-partial-results-each-time-it-is-run/58183 "2016-08-16T20:10:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mashbourne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mashbourne/32/10328_2.png) [@mashbourne](https://discuss.elastic.co/u/mashbourne)\
**Post date:** [August 16, 2016, 8:10pm UTC](https://discuss.elastic.co/t/match-query-returns-different-number-of-partial-results-each-time-it-is-run/58183/1 "2016-08-16T20:10:13Z")

</div>

One property with mapping "type": "string" and value "ReadingWonders2.0" is causing inconsistent query results.  
It seems to be analyzed inconsistently. When I query using match, I get a different number of hits each time I run the query.

If I use a term filter for both the original string and what \_analyze reports is the tokenized string, I get consistent results (same hits count each time I run the query) so it seems that some documents are being analyzed one way, and some the other...

**query returning inconsistent results:**

```
{
  "query": {
      "match": {
          "edApp.name": "ReadingWonders2.0"
      }
   }
}

```

hits.total values when running query multiple times: [44, 56, 57, 69]

**term query returning inconsistent results:**

```
{
    "query": {
        "bool": {
            "should": [
            {
                "term": {
                    "edApp.name": "ReadingWonders2.0"
                }
            }
            ]
        }
    }
}

```

hits.total values when running term query multiple times: [21, 33, 34, 46]

**Other term query returning inconsistent results (note lower case):**

```
{
    "query": {
        "bool": {
            "should": [
            {
                "term": {
                    "edApp.name": "readingwonders2.0"
                }
            }
            ]
        }
    }
}

```

hits.total values when running term query multiple times: [44, 56, 57, 69]  
NOTE: these are the same counts we saw with the match query!

**query with both terms:**

```
{
    "query": {
        "bool": {
            "should": [
            {
                "term": {
                    "edApp.name": "readingwonders2.0"
                }
            },
            {
                "term": {
                    "edApp.name": "ReadingWonders2.0"
                }
            }
            ]
        }
    }
}

```

hits.total values are consistent: 79 results

_ **The combined hits from lowercase, and camelcase term searches add up to the total 79 documents.** _

Any ideas why the match query is not finding some of the documents?

Using ES 1.5.2 through AWS Elasticsearch Service

---

<div class="post-metadata">

**Author:** ![mashbourne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mashbourne/32/10328_2.png) [@mashbourne](https://discuss.elastic.co/u/mashbourne)\
**Post date:** [August 16, 2016, 8:15pm UTC](https://discuss.elastic.co/t/match-query-returns-different-number-of-partial-results-each-time-it-is-run/58183/2 "2016-08-16T20:15:07Z")

</div>

I should add that there is a chance this is related to enabling doc\_values for other properties in my mapping. After that change is when this issue cropped up. Not sure how that would affect analyzed strings though, it may just be a red herring.

---

<div class="post-metadata">

**Author:** ![mashbourne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mashbourne/32/10328_2.png) [@mashbourne](https://discuss.elastic.co/u/mashbourne)\
**Post date:** [August 17, 2016, 1:57am UTC](https://discuss.elastic.co/t/match-query-returns-different-number-of-partial-results-each-time-it-is-run/58183/3 "2016-08-17T01:57:33Z")

</div>

I discovered that dynamic mapping was creating [generated.edApp.name](http://generated.edApp.name) field as "not\_analyzed" "doc\_values": true

This seems to conflict with [edApp.name](http://edApp.name) and cause documents to get mapped wrong!

---

<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, 10:27pm UTC](https://discuss.elastic.co/t/match-query-returns-different-number-of-partial-results-each-time-it-is-run/58183/4 "2017-07-05T22:27:26Z")

</div>


