Skip to content

Commit

Permalink
Removed changes for Null Searching
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszbieniek committed Oct 17, 2019
1 parent 39b80b9 commit f7c78d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 156 deletions.

This file was deleted.

54 changes: 9 additions & 45 deletions lib/Query/Common/CriterionVisitor/Field/FieldIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,17 @@
*/
namespace EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Field;

use eZ\Publish\SPI\Search\FieldType\BooleanField;
use EzSystems\EzPlatformSolrSearchEngine\FieldMapper\ContentTranslationFieldMapper\ContentDocumentNullFields;
use EzSystems\EzPlatformSolrSearchEngine\Query\CriterionVisitor;
use EzSystems\EzPlatformSolrSearchEngine\Query\Common\CriterionVisitor\Field;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Operator;
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException;
use eZ\Publish\Core\Search\Common\FieldValueMapper;
use eZ\Publish\Core\Search\Common\FieldNameResolver;
use eZ\Publish\Core\Search\Common\FieldNameGenerator;

/**
* Visits the Field criterion.
*/
class FieldIn extends Field
{
/**
* @var \eZ\Publish\Core\Search\Common\FieldNameGenerator
*/
private $fieldNameGenerator;

/**
* @param \eZ\Publish\Core\Search\Common\FieldNameResolver $fieldNameResolver
* @param \eZ\Publish\Core\Search\Common\FieldValueMapper $fieldValueMapper
* @param \eZ\Publish\Core\Search\Common\FieldNameGenerator $fieldNameGenerator
*/
public function __construct(FieldNameResolver $fieldNameResolver, FieldValueMapper $fieldValueMapper, FieldNameGenerator $fieldNameGenerator)
{
parent::__construct($fieldNameResolver, $fieldValueMapper);

$this->fieldNameGenerator = $fieldNameGenerator;
}

/**
* Check if visitor is applicable to current criterion.
*
Expand Down Expand Up @@ -78,33 +56,19 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null)
);
}

if ($criterion->value === null) {
$criterion->value[] = null;
} else {
$criterion->value = (array)$criterion->value;
}
$criterion->value = (array)$criterion->value;
$queries = array();

foreach ($searchFields as $name => $fieldType) {
foreach ($criterion->value as $value) {
if ($value === null) {
$name = $this->fieldNameGenerator->getTypedName(
$this->fieldNameGenerator->getName(
ContentDocumentNullFields::IS_NULL_NAME,
$criterion->target
),
new BooleanField()
);
$queries[] = $name . ':true';
} else {
$preparedValue = $this->escapeQuote(
$this->toString(
$this->mapSearchFieldValue($value, $fieldType)
),
true
);
$queries[] = $name . ':"' . $preparedValue . '"';
}
$preparedValue = $this->escapeQuote(
$this->toString(
$this->mapSearchFieldValue($value, $fieldType)
),
true
);

$queries[] = $name . ':"' . $preparedValue . '"';
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/Resources/config/container/solr/criterion_visitors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ services:
arguments:
- "@ezpublish.search.common.field_name_resolver"
- "@ezpublish.search.common.field_value_mapper.aggregate"
- "@ezpublish.search.common.field_name_generator"
tags:
- {name: ezpublish.search.solr.query.content.criterion_visitor}
- {name: ezpublish.search.solr.query.location.criterion_visitor}
Expand Down
9 changes: 0 additions & 9 deletions lib/Resources/config/container/solr/field_mappers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ services:
tags:
- {name: ezpublish.search.solr.field_mapper.location}

ezpublish.search.solr.field_mapper.content_translation.content_document_null_fields:
class: EzSystems\EzPlatformSolrSearchEngine\FieldMapper\ContentTranslationFieldMapper\ContentDocumentNullFields
arguments:
- '@ezpublish.spi.persistence.content_type_handler'
- '@ezpublish.search.common.field_name_generator'
- '@ezpublish.persistence.field_type_registry'
tags:
- {name: ezpublish.search.solr.field_mapper.content_translation}

ezpublish.search.solr.field_mapper.content_translation.content_document_empty_fields:
class: EzSystems\EzPlatformSolrSearchEngine\FieldMapper\ContentTranslationFieldMapper\ContentDocumentEmptyFields
arguments:
Expand Down

0 comments on commit f7c78d2

Please sign in to comment.