# Irrelevant result set

**URL:** https://discuss.elastic.co/t/irrelevant-result-set/33582
**Category:** Elasticsearch
**Created:** [November 2, 2015, 11:46pm UTC](https://discuss.elastic.co/t/irrelevant-result-set/33582 "2015-11-02T23:46:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pranesh002](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@pranesh002](https://discuss.elastic.co/u/pranesh002)
#### Post date: [November 2, 2015, 11:46pm UTC](https://discuss.elastic.co/t/irrelevant-result-set/33582/1 "2015-11-02T23:46:24Z")

</div>

I am getting irrelevant search results in ES. May be my query is wrong or may be issue with my mappings.  
Can some one help me to find the issue.

```auto
Mapping:
PUT /test
{  
   "mappings":{  
      "test":{  
         "properties":{  
            "customerId":{  
               "type":"string",
               "analyzer":"index_ngram",
               "search_analyzer":"search_ngram",
               "fields": {
                   "customerIdRaw":{
                       "type": "string", 
                       "index": "not_analyzed"
                   }
               }
            }
         }
      }
   },
   "settings":{  
      "analysis":{  
         "filter":{  
            "desc_ngram":{  
               "type":"ngram",
               "min_gram":8,
               "max_gram":20
            }
         },
         "analyzer":{  
            "index_ngram":{  
               "type":"custom",
               "tokenizer":"keyword",
               "filter":[  
                   "lowercase",
                   "desc_ngram"
               ]
            },
            "search_ngram":{  
               "type":"custom",
               "tokenizer":"keyword",
               "filter":["lowercase"]
            }
         }
      }
   }
}

JSON:

PUT test/test/1?pretty
{
  "customerId": "TESTING456",
  "phoneNo":"xxxxxx"
}

PUT test/test/2?pretty
{
  "customerId": "123",
  "phoneNo":"xxxxx"
}

Search Query:

POST /test/_search
"query": {"match": {
       "customerId": "123"
    }
    
Result:

{
   "took": 9,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 1,
      "hits": [
         {
            "_index": "test",
            "_type": "test",
            "_id": "2",
            "_score": 1,
            "_source": {
               "customerId": "123",
               "phoneNo": "xxxxxx"
            }
         },
         {
            "_index": "test",
            "_type": "test",
            "_id": "1",
            "_score": 1,
            "_source": {
               "customerId": "TESTING456",
               "phoneNo": "xxxxxx"
            }
         }
      ]
   }
}

```

Expected result is only one but it is returning all.

---

<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, 11:41pm UTC](https://discuss.elastic.co/t/irrelevant-result-set/33582/2 "2017-07-05T23:41:09Z")

</div>


