# Edge-ngram not working for single edge case!

**URL:** <https://discuss.elastic.co/t/edge-ngram-not-working-for-single-edge-case/309059>\
**Category:** Elasticsearch\
**Created:** [July 7, 2022, 12:18am UTC](https://discuss.elastic.co/t/edge-ngram-not-working-for-single-edge-case/309059 "2022-07-07T00:18:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![corndog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corndog/32/96803_2.png) [@corndog](https://discuss.elastic.co/u/corndog)\
**Post date:** [July 7, 2022, 12:18am UTC](https://discuss.elastic.co/t/edge-ngram-not-working-for-single-edge-case/309059/1 "2022-07-07T00:18:19Z")

</div>

My edge-ngram solution does not return any results for the following search:

```bash
"10th A"

```

Where 3 documents exist with the field values:

```auto
  "10th Avenue, Red Beach, New Zealand",
  "4 10th Avenue, Red Beach, New Zealand",
  "2 10th Avenue, Red Beach, New Zealand"

```

Query:

```auto
POST /addresses_nz/_search?pretty
{
  "_source": [
    "search_name"
  ],
  "size": 10, 
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "search_name.autocomplete": {
              "query": "10th A",
              "operator": "and",
              "fuzziness": 0
            }
          }
        }
      ],
      "should": [
        {
          "prefix": {
            "search_name.exact": {
              "value": "10th A"
            }
          }
        }
      ]
    }
  }
}

```

Index Mappings:

```auto
{
  "addresses_nz" : {
    "mappings" : {
      "properties" : {
        "search_name" : {
          "type" : "text",
          "fields" : {
            "autocomplete" : {
              "type" : "text",
              "analyzer" : "autocomplete_index",
              "search_analyzer" : "autocomplete_search"
            },
            "exact" : {
              "type" : "keyword"
            }
          }
        }
      }
    }
  }
}

```

Index Settings:

```auto
{
  "addresses_nz" : {
    "settings" : {
      "index" : {
        "analysis" : {
          "filter" : {
            "english_stopwords" : {
              "type" : "stop",
              "stopwords" : "_english_"
            }
          },
          "analyzer" : {
            "autocomplete_index" : {
              "filter" : [
                "lowercase",
                "english_stopwords"
              ],
              "type" : "custom",
              "tokenizer" : "autocomplete_index"
            },
            "autocomplete_search" : {
              "tokenizer" : "standard"
            }
          },
          "tokenizer" : {
            "autocomplete_index" : {
              "token_chars" : [
                "digit",
                "letter"
              ],
              "min_gram" : "1",
              "type" : "edge_ngram",
              "max_gram" : "15"
            }
          }
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 7, 2022, 7:06am UTC](https://discuss.elastic.co/t/edge-ngram-not-working-for-single-edge-case/309059/2 "2022-07-07T07:06:49Z")

</div>

You have different search and index time analyzers, which I suspect explain what you are seeing. Run the indexed string through the index time analyzer using the [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/8.2/indices-analyze.html) and then run the search string through the same API using the search time analyzer. If you compare the results I believe you will see that the tokens do not match up, e.g. there are no edge ngram token generated by the search time analyzer to match against the index.

---

<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 4, 2022, 7:07am UTC](https://discuss.elastic.co/t/edge-ngram-not-working-for-single-edge-case/309059/3 "2022-08-04T07:07:06Z")

</div>

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