Edgengram remove first letter - no results

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

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"
            }
          }
        }
      }
    }

You could use a multi field 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....

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?!

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