UnsupportedElasticsearchDefinitionException example

use Shopware\Elasticsearch\Exception\UnsupportedElasticsearchDefinitionException;

/** * @internal * * @covers \Shopware\Elasticsearch\Exception\UnsupportedElasticsearchDefinitionException */
class UnsupportedElasticsearchDefinitionExceptionTest extends TestCase
{
    public function testException(): void
    {
        $exception = new UnsupportedElasticsearchDefinitionException('product');
        static::assertStringContainsString('Entity product is not supported for elastic search', $exception->getMessage());
        static::assertSame('ELASTICSEARCH_UNSUPPORTED_DEFINITION', $exception->getErrorCode());
    }
}


    public function addTerm(Criteria $criteria, Search $search, Context $context, EntityDefinition $definition): void
    {
        if (!$criteria->getTerm()) {
            return;
        }

        $esDefinition = $this->registry->get($definition->getEntityName());

        if (!$esDefinition) {
            throw new UnsupportedElasticsearchDefinitionException($definition->getEntityName());
        }

        $query = $esDefinition->buildTermQuery($context$criteria);

        $search->addQuery($query);
    }

    public function addQueries(EntityDefinition $definition, Criteria $criteria, Search $search, Context $context): void
    {
        $queries = $criteria->getQueries();
        if (empty($queries)) {
            
Home | Imprint | This part of the site doesn't use cookies.