# \_all field matching fewer results

**URL:** <https://discuss.elastic.co/t/all-field-matching-fewer-results/155587>\
**Category:** Elasticsearch\
**Created:** [November 6, 2018, 5:44pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587 "2018-11-06T17:44:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luka](https://avatars.discourse-cdn.com/v4/letter/l/a587f6/32.png) [@luka](https://discuss.elastic.co/u/luka)\
**Post date:** [November 6, 2018, 5:44pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/1 "2018-11-06T17:44:34Z")

</div>

Hi!

I have a request of this form:

POST [http://localhost:9200/\_search](http://localhost:9200/_search)  
{  
"query": {  
"match": {  
"\_all": {  
"query": "foo bar",  
"operator": "and"  
}  
}  
},  
"size": 20  
}

and it returns fewer hits than this one:

POST [http://localhost:9200/\_search](http://localhost:9200/_search)  
{  
"query": {  
"match": {  
"baz": {  
"query": "foo bar",  
"operator": "and"  
}  
}  
},  
"size": 20  
}

Does this make any sense?

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 6, 2018, 6:10pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/2 "2018-11-06T18:10:14Z")

</div>

Yes it is pretty obvious.  
In the first search, you are searching in all fields via `_all`.  
The second query, searches only within field named `baz`. Hence, the second query results are bound to be lesser and a subset of the first query results.

---

<div class="post-metadata">

**Author:** ![luka](https://avatars.discourse-cdn.com/v4/letter/l/a587f6/32.png) [@luka](https://discuss.elastic.co/u/luka)\
**Post date:** [November 7, 2018, 9:07am UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/3 "2018-11-07T09:07:10Z")

</div>

Thank you Jaspreet\_Singh. That would be obvious to me too. The problem that I'm facing is the other way round - I get fewer results when using \_all.

Other things I know I use is ngram filter and boost.

I would really like to know what's going on. If you know a good debugging technique, please share.

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 7, 2018, 3:46pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/4 "2018-11-07T15:46:40Z")

</div>

My bad and I apologize for overlooking that detail.  
Can you share your mappings as well?

---

<div class="post-metadata">

**Author:** ![luka](https://avatars.discourse-cdn.com/v4/letter/l/a587f6/32.png) [@luka](https://discuss.elastic.co/u/luka)\
**Post date:** [November 8, 2018, 1:22pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/5 "2018-11-08T13:22:59Z")

</div>

I can't. At least I think, in this direction, I would have to make a complete example to prove the case, including data. But I can say that I've noticed that, apart from the mapping being "normal", only a few prebuilt analyzers make consistent results. It feels like \_all will always use one of those analyzers. The standard analyzer maybe.

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 9, 2018, 3:19pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/6 "2018-11-09T15:19:15Z")

</div>

So here is something I put together, using all defaults (including analyzer standard for text types). It gives exactly expected results, search in \_all gives more results than a search in specific field.

```auto
PUT test_all
{
  "mappings": {
    "docs":{
      "properties": {
        "title":{
          "type": "text"
        },
        "body":{
          "type": "text"
        }
      }
    }
  }
}

PUT test_all/docs/1
{
  "title":"foo bar",
  "body":"nothing"
}
PUT test_all/docs/2
{
  "title":"nothing",
  "body":"foo bar"
}

GET test_all/_search
{
  "query": {
    "match": {
      "_all": {
        "query": "foo bar",
        "operator": "and"
      }
    }
  }
}

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 0.5063205,
    "hits": [
      {
        "_index": "test_all",
        "_type": "docs",
        "_id": "2",
        "_score": 0.5063205,
        "_source": {
          "title": "nothing",
          "body": "foo bar"
        }
      },
      {
        "_index": "test_all",
        "_type": "docs",
        "_id": "1",
        "_score": 0.5063205,
        "_source": {
          "title": "foo bar",
          "body": "nothing"
        }
      }
    ]
  }
}

GET test_all/_search
{
"query": {
    "match": {
      "title": {
        "query": "foo bar",
        "operator": "and"
      }
    }
  }
}

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0.51623213,
    "hits": [
      {
        "_index": "test_all",
        "_type": "docs",
        "_id": "1",
        "_score": 0.51623213,
        "_source": {
          "title": "foo bar",
          "body": "nothing"
        }
      }
    ]
  }
}

```

---

<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:** [December 7, 2018, 3:19pm UTC](https://discuss.elastic.co/t/all-field-matching-fewer-results/155587/7 "2018-12-07T15:19:28Z")

</div>

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