# Match query does not give expected result

**URL:** <https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878>\
**Category:** Elasticsearch\
**Created:** [August 17, 2018, 10:05am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878 "2018-08-17T10:05:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bongoD6](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bongoD6](https://discuss.elastic.co/u/bongoD6)\
**Post date:** [August 17, 2018, 10:05am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878/1 "2018-08-17T10:05:46Z")

</div>

Hi,

I am not sure if I am doing something wrong, but I cant see expected results for match query.  
I have followed ES documents and tried making a curl request with below json body

```
{
    "query": {
        "match" : {
            "title" : {
                "query" : "this test",
                "operator" : "or"
            }
        }
    }
} 

```

Complete title value is: "this is a test". Though when I make a call using below equivalent bool query, I am getting results:

```
  {
"query" :{
  "bool": {
"should": [
  { "term": { "title": "this" }},
  { "term": { "title": "test" }}
]
  }
  }
  }
```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 17, 2018, 10:32am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878/2 "2018-08-17T10:32:28Z")

</div>

can you provide a **fully reproducible example** including index/mapping creation and indexing of documents? This way it is easier to follow your problem.

---

<div class="post-metadata">

**Author:** ![bongoD6](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bongoD6](https://discuss.elastic.co/u/bongoD6)\
**Post date:** [August 17, 2018, 10:53am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878/3 "2018-08-17T10:53:47Z")

</div>

Hi Reelsen,

Thanks for quick response. Below are curl call results:

`curl http://localhost:9201/esIndex`

` {"esIndex":{"aliases":{},"mappings":{"esType":{"properties":{"@timestamp":{"type":"date"},"@version":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"alias":{"type":"text","analyzer":"str_index_analyzer","search_analyzer":"str_search_analyzer"},"boost_value":{"type":"long"},"category":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"pub_date":{"type":"long"},"search_suggetion":{"type":"boolean"},"tag":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"title":{"type":"text","analyzer":"str_index_analyzer","search_analyzer":"str_search_analyzer"},"type":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}}}}},"settings":{"index":{"number_of_shards":"5","provided_name":"esIndex","creation_date":"1530625714142","analysis":{"filter":{"substring":{"type":"nGram","min_gram":"1","max_gram":"20"}},"analyzer":{"str_index_analyzer":{"filter":["lowercase","substring"],"tokenizer":"keyword"},"str_search_analyzer":{"filter":["lowercase"],"tokenizer":"keyword"}}},"number_of_replicas":"1","uuid":"<uuid>","version":{"created":"6020399"}}}}}`

Inserting records :

```
curl -X PUT "localhost:9201/esindex/estype/<id>" -H 'Content-Type: application/json' -d'
{
 "pub_date": 1520346474000,
    "@timestamp": "2018-03-06T14:27:54.666Z",
    "boost_value": 1,
    "search_suggetion": false,
    "@version": "1",
    "alias": "this is a test",
    "id": "<id>",
    "tag": "test",
    "type": "estype",
    "title": "this is a test",
}' 

```

`/_cat/indices gievs below output:`

> green open esindex uuid 5 1 14 0 976.9kb 488.4kb

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 17, 2018, 11:54am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878/4 "2018-08-17T11:54:02Z")

</div>

See this example

```auto
POST esindex/_analyze
{
  "analyzer" : "str_index_analyzer",
  "text" : "this is a test"
}

POST esindex/_analyze
{
  "analyzer" : "str_search_analyzer",
  "text" : "this test"
}

```

the output of the second analyze call just returns `this test` and this token is not emitted by the first call and thus never stored in the inverted index.

---

<div class="post-metadata">

**Author:** ![bongoD6](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bongoD6](https://discuss.elastic.co/u/bongoD6)\
**Post date:** [August 20, 2018, 6:45am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878/5 "2018-08-20T06:45:30Z")

</div>

Thanks a lot Reelsen.

Fixed it, and got better picture of ES.

---

<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:** [September 17, 2018, 6:45am UTC](https://discuss.elastic.co/t/match-query-does-not-give-expected-result/144878/6 "2018-09-17T06:45:40Z")

</div>

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