I'm trying to setup Elastic Search on an existing catalog that works fine under standard MySQL search. I go through the documentation and it seems straightforward. This is Magento 2.3.2 and ElasticSearch 6 (version 6.7.1).
The documentation says to just select it and reindex. It feels like there must be some extra step that I'm not clear on. After doing so, all I get on every category page is "We can't find products matching the selection."
I've done all of the basics (clearing all caches and temp files, reindexing). The solution found here is not a change to what my file already has (copied below). Again, these are established categories and they are all empty.
What am I missing? Or, what should I be looking for?
Edit: if it helps here is the result of curl -i http://localhost:9200/_cluster/health
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 389
{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":50.0}
Edit: Per the comment below I've included the source of the file vendor/magento/module-elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php
:
This is Magento 2.3.2 and I don't make local edits to vendor files.
namespace Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection;
use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\SearchResultApplierInterface;
use Magento\Framework\Data\Collection;
use Magento\Framework\Api\Search\SearchResultInterface;
/**
* Resolve specific attributes for search criteria.
*/
class SearchResultApplier implements SearchResultApplierInterface
{
/**
* @var Collection|\Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection
*/
private $collection;
/**
* @var SearchResultInterface
*/
private $searchResult;
/**
* @param Collection $collection
* @param SearchResultInterface $searchResult
*/
public function __construct(
Collection $collection,
SearchResultInterface $searchResult
) {
$this->collection = $collection;
$this->searchResult = $searchResult;
}
/**
* @inheritdoc
*/
public function apply()
{
if (empty($this->searchResult->getItems())) {
$this->collection->getSelect()->where('NULL');
return;
}
$ids = [];
foreach ($this->searchResult->getItems() as $item) {
$ids[] = (int)$item->getId();
}
$this->collection->setPageSize(null);
$this->collection->getSelect()->where('e.entity_id IN (?)', $ids);
$orderList = join(',', $ids);
$this->collection->getSelect()->reset(\Magento\Framework\DB\Select::ORDER);
$this->collection->getSelect()->order("FIELD(e.entity_id,$orderList)");
}
}
Progress: In exceptions.log I have the error: "type":"query_shard_exception", "reason":"No mapping found for [position_category_#] in order to sort on"
The whole thing:
main.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [position_category_104] in order to sort on","index_uuid":"bLDcJEDeQ_eyRQOQYHppzQ",
"index":"magento2_product_1_v1"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2_product_1_v1","node":"ZGUdm6aHRU6RShqrqU3xfQ","reason":{"type":"query_shard_exception","reason":"No mapping found for [position_category_104] in order to sort on","index_uuid":"bLDcJEDeQ_eyRQOQYHppzQ","index":"magento2_product_1_v1"}}]},"status":400} {"exception":"[object] (Elasticsearch\\Common\\Exceptions\\BadRequest400Exception(code: 400): {\"error\":{\"root_cause\":[{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [position_category_104] in order to sort on\",\"index_uuid\":\"bLDcJEDeQ_eyRQOQYHppzQ\",\"index\":\"magento2_product_1_v1\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":0,\"index\":\"magento2_product_1_v1\",\"node\":\"ZGUdm6aHRU6RShqrqU3xfQ\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [position_category_104] in order to sort on\",\"index_uuid\":\"bLDcJEDeQ_eyRQOQYHppzQ\",\"index\":\"magento2_product_1_v1\"}}]},\"status\":400} at /opt/bitnami/apps/magento/htdocs/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:636)"} []
curl http://localhost:9200/_cat/indices
command execution against your ES instance?