Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-31275

IsEmptyCritetion is omitted in LocationQuery with Solr as search engine

    XMLWordPrintable

Details

    Description

      Using SearchService findLocation method will not find any records using IsEmptyCriterion when Solr is set as an search engine.

      Steps to reproduce
      1. Clean installation of eZ Platform 2.5.8 with Solr as search engine.
      2. Create a new Command in AppBundle/Command:

      <?php
      
      namespace AppBundle\Command;
      
      use eZ\Publish\API\Repository\SearchService;
      use eZ\Publish\API\Repository\Values\Content\LocationQuery;
      use eZ\Publish\API\Repository\Values\Content\Query;
      use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
      use Symfony\Component\Console\Input\InputInterface;
      use Symfony\Component\Console\Output\OutputInterface;
      
      class SearchCommand extends ContainerAwareCommand
      {
          /** @var \eZ\Publish\API\Repository\SearchService */
          private $searchService;
      
          public function __construct(SearchService $searchService)
          {
              $this->searchService = $searchService;
      
              parent::__construct(null);
          }
      
          protected function configure()
          {
              $this->setName('app:search');
          }
      
          protected function execute(InputInterface $input, OutputInterface $output)
          {
              try{
                  $query = new LocationQuery();
                  $query->query = new Query\Criterion\IsFieldEmpty('short_name');
      
                  $results = $this->searchService->findLocations($query);
                  $output->writeln('Found: ' . count($results->searchHits));
                  
              } catch (\Exception $e) {
                  $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
              }
          }
      }
      

      and add its definition to app/config/services.yml:

      services:
          # default configuration for services in *this* file
          _defaults:
              # automatically injects dependencies in your services
              autowire: true
              # automatically registers your services as commands, event subscribers, etc.
              autoconfigure: true
              # this means you cannot fetch services directly from the container via $container->get()
              # if you need to do this, you can override this setting on individual services
              public: false
      
          AppBundle\Command\SearchCommand: ~
      

      3. Execute command php bin/console app:search

      Result
      0 locations found.

      Expected Result
      5 locations found.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mateusz.bieniek@ibexa.co Mateusz Bieniek
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: