spark-solutions / spree2vuestorefront

Build complete E-Commerce PWA with this Spree Commerce (https://github.com/spree/spree) to Vue Storefront (https://github.com/DivanteLtd/vue-storefront) bridge
50 stars 9 forks source link

cannot initializes Elastic Search ./bin/exec yarn create-indices #93

Open GinFoB opened 4 years ago

GinFoB commented 4 years ago

Hi everyone

I can't initializes Elastic Search by using cmd ./bin/exec yarn create-indices. This is my first time using E-Commerce PWA "Vue Storefront". and Elastic Search. My error

{ "message": [ "Error: Cannot create indices or set proper settings and mapping.", { "msg": "[illegal_argument_exception] The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [1] but was [6]. This limit can be set by changing the [index.max_ngram_diff] index level setting.", "path": "/vue_storefront_catalog", "query": {}, "body": "{\"settings\":{\"analysis\":{\"analyzer\":{\"ngram_analyzer\":{\"tokenizer\":\"ngram_tokenizer\",\"filter\":\"lowercase\"}},\"tokenizer\":{\"ngram_tokenizer\":{\"type\":\"ngram\",\"min_gram\":2,\"max_gram\":8,\"token_chars\":[\"letter\",\"digit\"]}}}},\"mappings\":{\"product\":{\"properties\":{\"sku\":{\"type\":\"keyword\"},\"size\":{\"type\":\"keyword\"},\"color\":{\"type\":\"keyword\"},\"name\":{\"type\":\"text\",\"index\":\"analyzed\",\"analyzer\":\"ngram_analyzer\"}}},\"category\":{\"properties\":{\"url_key\":{\"type\":\"keyword\"}}}}}", "statusCode": 400, "response": "{\"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 [6]. 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 [6]. This limit can be set by changing the [index.max_ngram_diff] index level setting.\"},\"status\":400}" } ], "level": "error", "timestamp": "2020-04-07T22:26:59.553Z" }

When i change max_gram and min_gram to 8, 8 , i get another error like below :

{ "message": [ "Error: Cannot create indices or set proper settings and mapping.", { "msg": "[mapper_parsing_exception] Root mapping definition has unsupported parameters: [product : {properties={size={type=keyword}, color={type=keyword}, name={analyzer=ngram_analyzer, index=analyzed, type=text}, sku={type=keyword}}}] [category : {properties={url_key={type=keyword}}}]", "path": "/vue_storefront_catalog", "query": {}, "body": "{\"settings\":{\"analysis\":{\"analyzer\":{\"ngram_analyzer\":{\"tokenizer\":\"ngram_tokenizer\",\"filter\":\"lowercase\"}},\"tokenizer\":{\"ngram_tokenizer\":{\"type\":\"ngram\",\"min_gram\":8,\"max_gram\":8,\"token_chars\":[\"letter\",\"digit\"]}}}},\"mappings\":{\"product\":{\"properties\":{\"sku\":{\"type\":\"keyword\"},\"size\":{\"type\":\"keyword\"},\"color\":{\"type\":\"keyword\"},\"name\":{\"type\":\"text\",\"index\":\"analyzed\",\"analyzer\":\"ngram_analyzer\"}}},\"category\":{\"properties\":{\"url_key\":{\"type\":\"keyword\"}}}}}", "statusCode": 400, "response": "{\"error\":{\"root_cause\":[{\"type\":\"mapper_parsing_exception\",\"reason\":\"Root mapping definition has unsupported parameters: [product : {properties={size={type=keyword}, color={type=keyword}, name={analyzer=ngram_analyzer, index=analyzed, type=text}, sku={type=keyword}}}] [category : {properties={url_key={type=keyword}}}]\"}],\"type\":\"mapper_parsing_exception\",\"reason\":\"Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [product : {properties={size={type=keyword}, color={type=keyword}, name={analyzer=ngram_analyzer, index=analyzed, type=text}, sku={type=keyword}}}] [category : {properties={url_key={type=keyword}}}]\",\"caused_by\":{\"type\":\"mapper_parsing_exception\",\"reason\":\"Root mapping definition has unsupported parameters: [product : {properties={size={type=keyword}, color={type=keyword}, name={analyzer=ngram_analyzer, index=analyzed, type=text}, sku={type=keyword}}}] [category : {properties={url_key={type=keyword}}}]\"}},\"status\":400}" } ], "level": "error", "timestamp": "2020-04-07T22:33:44.851Z" }

Anyone can help me, so many thanks

tniezg commented 4 years ago

Hi and welcome. Can you please provide the version of Elastic Search you're using? Thanks!

GinFoB commented 4 years ago

Hi @tniezg , I use elasticsearch 7.6. Thanks.

tniezg commented 4 years ago

Thanks 👍 spree2vs supports Elastic Search 5.6.11. The default ES version used in vue-storefront-api is also 5.6.11 and support for ES 7 is currently experimental.

GinFoB commented 4 years ago

@tniezg thanks, now i get new error

"message": [ "Error: Cannot create indices or set proper settings and mapping.", { "msg": "[security_exception] missing authentication token for REST request [/vue_storefront_catalog], with { header={ WWW-Authenticate=\"Basic realm=\\"security\\" charset=\\"UTF-8\\"\" } }",

Can you explain me and thanks a lot.

tniezg commented 4 years ago

It looks like your Elastic Search instance requires a user and password. You can set them by modifying ES_URL like so: https://<user>:<password>@es_host:es_port. Or you can remove authentication from Elastic Search by running bin/elasticsearch-plugin remove x-pack --purge (https://github.com/DivanteLtd/vue-storefront-api/blob/master/docker/elasticsearch/Dockerfile).

GinFoB commented 4 years ago

@tniezg thanks it work from me by run this command

docker run -p 9200:9200 -e 'xpack.security.enabled=false' -e 'xpack.monitoring.enabled=false' docker.elastic.co/elasticsearch/elasticsearch:5.6.11

Now i get this error

{ "message": [ "Could not download page.", { "name": "NoResponseError", "message": "No response received from Spree", "stack": "NoResponseError: No response received from Spree\n at e.LIMITED (/app/node_modules/@spree/storefront-api-v2-sdk/dist/server/webpack:/src/Http.ts:64:23)\n at e.route (/app/node_modules/@spree/storefront-api-v2-sdk/dist/server/webpack:/src/Http.ts:42:29)\n at Generator.throw ()\n at s (/app/node_modules/@spree/storefront-api-v2-sdk/dist/server/webpack:/src/interfaces/errors/ErrorClass.ts:1:23)\n at process._tickCallback (internal/process/next_tick.js:68:7)" } ], "level": "error", "timestamp": "2020-04-08T13:36:12.842Z" }

Give me an idea how can i solve it, thanks a lot @tniezg

tniezg commented 4 years ago

This means Spree is not available. The default URL for Spree is http://host.docker.internal:8812 (127.0.0.1 host.docker.internal in /etc/hosts). It can be changed by modifying the SPREE_URL env variable.

GinFoB commented 4 years ago

@tniezg i have the same config

127.0.0.1 host.docker.internal in /etc/hosts

I still the same error.

But when i test http://127.0.0.1:3000/api/v2/storefront/products in my rest api client i get the list of products.

I can't found what i miss, if you can give me idea how can i solve it and thanks @tniezg

tniezg commented 4 years ago

The default port in spree2vs for Spree is 8812. Did you update the port to 3000?

GinFoB commented 4 years ago

Hi @tniezg,

I don't update the port to 3000, but when i start my spree app using 8812 port non error show in import products.

Now when i start app using ./bin/exec yarn server i get a lot of message like

{ "message": "Request for / could not be handled", "level": "info", "timestamp": "2020-04-09T09:18:25.636Z" }

And in the browser using http://localhost:8889/ i get {code: 500}

What i miss again, and how to update the default port in spree2vs and thanks @tniezg

tniezg commented 4 years ago

./bin/exec yarn server is used by Vue Storefront. VS will issue requests like /api/cart/pull?token=.... Please start Vue Storefront and set it to call http://localhost:8889. You need to update configuration: "cart", "orders", "users", "stock"

GinFoB commented 4 years ago

@tniezg thank you

shunnokw commented 3 years ago

Hi @tniezg,

I don't update the port to 3000, but when i start my spree app using 8812 port non error show in import products.

Now when i start app using ./bin/exec yarn server i get a lot of message like

{ "message": "Request for / could not be handled", "level": "info", "timestamp": "2020-04-09T09:18:25.636Z" }

And in the browser using http://localhost:8889/ i get {code: 500}

What i miss again, and how to update the default port in spree2vs and thanks @tniezg

I also have the same error code 505 while calling http://localhost:8889/, is that normal? How did you fix this? Thank you

tniezg commented 3 years ago

Hi @tniezg, I don't update the port to 3000, but when i start my spree app using 8812 port non error show in import products. Now when i start app using ./bin/exec yarn server i get a lot of message like

{ "message": "Request for / could not be handled", "level": "info", "timestamp": "2020-04-09T09:18:25.636Z" }

And in the browser using http://localhost:8889/ i get {code: 500} What i miss again, and how to update the default port in spree2vs and thanks @tniezg

I also have the same error code 505 while calling http://localhost:8889/, is that normal? How did you fix this? Thank you

Hi @shunnokw. spree2vuestorefront's server has a catch-all route - https://github.com/spark-solutions/spree2vuestorefront/blob/master/src/server/index.ts#L768. The path / is not handled by the server. Routes such as /api/cart/pull and /api/cart/payment-methods are handled. All the available routes can be examined in the https://github.com/spark-solutions/spree2vuestorefront/blob/master/src/server/index.ts file.

sangamu commented 3 years ago

I am also getting similar issue while executing create-indices. Could someone help please? Here is the output of running ./bin/exec yar create-indices

./bin/exec yarn create-indices Recreating spree2vuestorefront_spree2vs_1 ... done yarn run v1.17.3 $ ./dist/index.js create-indices { "message": "Creating index.", "level": "info", "timestamp": "2021-07-10T10:37:29.396Z" } { "message": "Creating index.", "level": "info", "timestamp": "2021-07-10T10:37:29.398Z" } Elasticsearch ERROR: 2021-07-10T10:37:29Z Error: Request error, retrying PUT http://127.0.0.1:9200/vue_storefront_catalog => connect ECONNREFUSED 127.0.0.1:9200 at Log.error (/app/node_modules/elasticsearch/src/lib/log.js:226:56) at checkRespForFailure (/app/node_modules/elasticsearch/src/lib/transport.js:259:18) at HttpConnector. (/app/node_modules/elasticsearch/src/lib/connectors/http.js:164:7) at ClientRequest.wrapper (/app/node_modules/lodash/lodash.js:4949:19) at ClientRequest.emit (events.js:198:13) at Socket.socketErrorListener (_http_client.js:392:9) at Socket.emit (events.js:198:13) at emitErrorNT (internal/streams/destroy.js:91:8) at emitErrorAndCloseNT (internal/streams/destroy.js:59:3) at process._tickCallback (internal/process/next_tick.js:63:19)

{ "message": [ "Error: Cannot create indices or set proper settings and mapping.", { "message": "No Living connections", "name": "Error", "stack": "Error: No Living connections\n at sendReqWithConnection (/app/node_modules/elasticsearch/src/lib/transport.js:226:15)\n at next (/app/node_modules/elasticsearch/src/lib/connection_pool.js:214:7)\n at process._tickCallback (internal/process/next_tick.js:61:11)" } ], "level": "error", "timestamp": "2021-07-10T10:37:29.436Z" }

If i put http://127.0.0.1:9200/vue_storefront_catalog in browser, I get following output: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"vue_storefront_catalog","index_uuid":"na","index":"vue_storefront_catalog"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"vue_storefront_catalog","index_uuid":"na","index":"vue_storefront_catalog"},"status":404}

That means the url is valid. But while executing create-indices, it shows connection to 9200 port of localhost was refused. Could someone shed light on what I am missing?

My elastic version is 5.6.11. Spree is on at 3000 port and working fine.

Thanks.