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

Searching for Content with empty field will result on Error when using Solr

    XMLWordPrintable

Details

    Description

      Using Criterion\Field for searching for Contents with fields that are empty will make Solr throw an exception.

      Steps to reproduce
      1. Clean installation of eZ Platform 2.5.5
      2. Create a test Command:

      <?php
      //src/AppBundle/Command/SearchCommand.php
      
      namespace AppBundle\Command;
      
      use eZ\Publish\API\Repository\SearchService;
      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
      {
          protected function configure()
          {
              $this->setName('app:search');
          }
      
          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $repository = $this->getContainer()->get('ezpublish.api.repository');
      
              /** @var SearchService $searchService */
              $searchService = $repository->getSearchService();
      
              $testQuery = new Query();
              $testQuery->query = new Query\Criterion\LogicalAnd([
                  new Query\Criterion\ContentTypeIdentifier('folder'),
                  new Query\Criterion\Field('short_name', Query\Criterion\Operator::EQ, NULL),
              ]);
      
              $searchResult = $searchService->findContent($testQuery);
      
              foreach ( $searchResult->searchHits as $searchHit )
              {
                  $output->writeln( $searchHit->valueObject->contentInfo->name );
              }
          }
      }
      

      3. Set Solr as a search engine.
      4. Run bin/console app:search.

      Result
      Command will fail with Solr ParseException.

      Excepted Result
      All folders with short_name not set are returned.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: