1

Installed details: Magento 2.4.2, Elasticsearch 7.6.0, Ububtu 20.04.

Elasticsearch is working on localhost:9200.

{
  "name" : "magento",
  "cluster_name" : "my-application",
  "cluster_uuid" : "bp8QVARQTxavGac9XSUadw",
  "version" : {
    "number" : "7.6.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
    "build_date" : "2020-02-06T00:09:00.449973Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

I made the necessary configurations in the Stores/Configurations/Catalog/Catalog/Catalog Search.

enter image description here

then php bin/magento cache:clean and bin/magento indexer:reindex, then tried to search.

But the problem is that the search does not work on the Luma page:

enter image description here

I checked http://127.0.0.1:9200/_cat/indices?v:

health status index                            uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   magento2_es_demo5x1_product_1_v2 W4E0HOGtTd6Y4LCBWvo3-w   1   1          0            0       283b           283b
yellow open   magento2_product_1_v9            YerIXZhrSii_b5wxarJ6hA   1   1          0            0       283b           283b

checked http://127.0.0.1:9200/magento2_product_1_v9/_search?pretty=true:

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  }
}

(I can provide the necessary details).

Just started learning Magento and ElasticSearch, so I really ask the community to tell me in detail what to do to make ElasticSearch work in my Magento project.

3 Answers 3

0

It looks like your Elasticsearch search server is working and Magento 2 can communicate with it which is great, but looking at the tests you did the magento2 index is empty.

Make sure you have ran the indexers

bin/magento index:reindex

or just to reindex search

bin/magento indexer:reindex catalogsearch_fulltext

Test your search again from the command line (or browser) with

curl -XGET 'localhost:9200/magento2_product_1_vXXX/_search?q=name:simple&pretty'

http://127.0.0.1:9200/magento2_product_1_vXXX/_search?q=name:simple&pretty:

3
  • bin/magento indexer:reindex catalogsearch_fulltext (rebuilt successfully ). the second command throws an error(magento2_product_1_vXXX/ magento2_product_1_v9) -> ( "type" : "index_not_found_exception", "reason" : "no such index [magento2_product_2_vXXX]",). What should be my next steps
    – David
    Commented Mar 11, 2021 at 8:36
  • You must add the index name from your server - you see it with the _cat/indices command, or simply try your frontend search for "simple" again.
    – paj
    Commented Mar 11, 2021 at 8:47
  • 1
    By the looks of it, you have the index created but it has no products indexed inside it. Probably a redundant thing, but you do have products which are enabled and set with visibility 'Catalog, Search' OR 'Search', right?
    – Diana
    Commented Mar 11, 2021 at 10:41
0

To verify that Elasticsearch is working, enter the following command on the server on which it is running:

curl -XGET ':9200/_cat/health?v&pretty' A message similar to the following is displayed:

epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks 1519701563 03:19:23 elasticsearch green 1 1 0 0 0 0 0 0

Document: https://devdocs.magento.com/guides/v2.4/config-guide/elasticsearch/configure-magento.html https://vrajeshpatel.in/2020/08/23/magento-2-4-0-getting-error-could-not-validate-a-connection-to-elasticsearch/

0

Make sure you have selected Website in the sales Channel section of edit stockenter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.