cancel
Showing results for 
Search instead for 
Did you mean: 

Reindex Showing unknown Error

Reindex Showing unknown Error

UI did upgrade my magento 2.3.4 to 2.4.2.

I did remove my elastic search v6.2.x and installed a new one v 7.0.0.

Then tried to reindex through terminal it showing error like

 

Catalog Search index process unknown error:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [1] but was [2]. This limit can be set by changing the [index.max_ngram_diff] index level setting."}],"type":"illegal_argument_exception","reason":"The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [1] but was [2]. This limit can be set by changing the [index.max_ngram_diff] index level setting."},"status":400}

 

 

How to I fix this issue..

I did try 

curl -X PUT "localhost:9200/my-index-000001/_settings?pretty" -H 'Content-Type: application/json' -d'{"index" : {"max_ngram_diff" : "50"}}'

 

Then restart the ElaticSearch this time showing

"Catalog Search index exception: Could not ping search engine: No alive nodes found in your cluster"

 

Again tried the reindex comment but again it showing the first unknown error.

 

How to I fix this issue. Please give me a solution

kalathinkal
2 REPLIES 2

Re: Reindex Showing unknown Error

Please share if any solution.

kalathinkal

Re: Reindex Showing unknown Error


@vipinsimpl4aed wrote:

Please share if any solution.



Basically, by Default, the difference between max_gram and min_gram in NGram Tokenizer can't be more than 1 and if you want you to change this, then in your index settings you need to change it by adding below setting.

"max_ngram_diff" : "50" --> you can mention this number accoding to your requirement.

Below is my index settings, where you can see I have a difference of 47 in my max_gram and min_gram hence set max_ngram_diff to 50.

{ 
    "settings": {
        "index": {
            "analysis": {
                "analyzer": {
                    "prefix": {
                        "type": "custom",
                        "filter": [
                            "lowercaseFilter"
                        ],
                        "tokenizer": "edgeNGramTokenizer"
                    }
                },
                "tokenizer": {
                    "edgeNGramTokenizer": {
                        "token_chars": [
                            "letter",
                            "digit"
                        ],
                        "min_gram": "1",
                        "type": "edgeNGram",
                        "max_gram": "40"
                    },
                    "loginNGram": {
                        "type": "nGram",
                        "min_gram": "3",
                        "max_gram": "50"
                    }
                }
            },
            "number_of_shards": "1",
            "number_of_replicas": "0",
            "max_ngram_diff" : "50"
        }
    }
} 

An official Elastic documentation, which explains that default length of max_gram is 2 and min_gram is 1, hence default difference between these can't be more than 1, hence the exception. And then snippet from the same doc

The index level setting index.max_ngram_diff controls the maximum allowed difference between max_gram and min_gram.