# Edgengram remove first letter - no results

**URL:** <https://discuss.elastic.co/t/edgengram-remove-first-letter-no-results/159883>\
**Category:** Elasticsearch\
**Created:** [December 7, 2018, 8:39am UTC](https://discuss.elastic.co/t/edgengram-remove-first-letter-no-results/159883 "2018-12-07T08:39:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktb](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@ktb](https://discuss.elastic.co/u/ktb)\
**Post date:** [December 7, 2018, 8:39am UTC](https://discuss.elastic.co/t/edgengram-remove-first-letter-no-results/159883/1 "2018-12-07T08:39:21Z")

</div>

Hello,

i use an analyzer with the edgengram tokenizer.

The problem is, when i remove the first letter from a searchquery, the result is empty.

Its clear that the edgengram creates only terms from the beginning of a phrase. So i think thats why it happens.

Using the ngram instead is no option i think, because the results are not exact enough.  
(i tried it)

As suggested  
[https://discuss.elastic.co/t/alternative-to-ngram-tokenizer-and-token-filter-substring-issue/53354](http://here)

I can try reverse edgengram.

I tried it but it looks like it will only search reverse then!?

How can i search both. non reverse and reverse?

Is this possible? Are there better solutions?

```
PUT edge-ngram-123
    {
      "settings": {
        "analysis": {
          "analyzer": {
            "autocomplete_index": {
              "type": "custom",
              "tokenizer": "autocomplete_token",
              "filter": [
                "lowercase"
              ]
            },
            "autocomplete_search": {
              "tokenizer": "lowercase"
            }
          },
          "tokenizer": {
            "autocomplete_token": {
              "type": "edge_ngram",
              "min_gram": 3,
              "max_gram": 10,
              "token_chars": [
                "letter",
                "digit"
              ]
            }
          }
        }
      },
      "mappings": {
        "product_suggester": {
          "properties": {
            "searchField": {
              "type": "text",
              "analyzer": "autocomplete_index",
              "search_analyzer": "autocomplete_search"
            },
            "ranking": {
              "type": "long"
            },
            "primaryId": {
              "type": "long"
            }
          }
        }
      }
    }
```

---

<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:** [December 7, 2018, 8:48am UTC](https://discuss.elastic.co/t/edgengram-remove-first-letter-no-results/159883/2 "2018-12-07T08:48:20Z")

</div>

You could use a [multi field](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/multi-fields.html) to store the data more than once in different ways, which then allows you to try out different search strategies, like the ones you mentioned above. Try a narrow search first and then widen the net....

---

<div class="post-metadata">

**Author:** ![ktb](https://avatars.discourse-cdn.com/v4/letter/k/7c8e57/32.png) [@ktb](https://discuss.elastic.co/u/ktb)\
**Post date:** [December 7, 2018, 9:00am UTC](https://discuss.elastic.co/t/edgengram-remove-first-letter-no-results/159883/3 "2018-12-07T09:00:25Z")

</div>

Hey spinscale,

thanks for your quick reply.

I will try it.

So isnt it the same, when i invert all my data and add it to the current data?!

---

<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:** [January 4, 2019, 9:00am UTC](https://discuss.elastic.co/t/edgengram-remove-first-letter-no-results/159883/4 "2019-01-04T09:00:26Z")

</div>

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