Skip to content
Snippets Groups Projects
Commit 19eb6500 authored by Andrew Chappell's avatar Andrew Chappell
Browse files

Merge branch search_api_opensearch:3.x into 3285438-the-whole-index

parents 3a6cfcc5 7ebc790f
No related branches found
No related tags found
No related merge requests found
Pipeline #198441 failed
Showing
with 55 additions and 21 deletions
......@@ -24,7 +24,7 @@ class GeoPointDataType extends DataTypePluginBase {
array $configuration,
$plugin_id,
$plugin_definition,
protected GeoPHPInterface $geoPHP
protected GeoPHPInterface $geoPHP,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
......
<?php
declare(strict_types=1);
namespace Drupal\Tests\search_api_opensearch_location\Kernel\Plugin\data_type;
use Drupal\geofield\GeoPHP\GeoPHPInterface;
......
......@@ -39,8 +39,3 @@ parameters:
message: "#^Variable \\$fields in empty\\(\\) is never defined\\.$#"
count: 1
path: src/SearchAPI/Query/QueryParamBuilder.php
-
message: "#^Variable \\$index in isset\\(\\) always exists and is not nullable\\.$#"
count: 1
path: tests/src/Kernel/MoreLikeThisParamBuilderKernelTest.php
......@@ -32,6 +32,9 @@ services:
search_api_opensearch.facet_builder:
class: Drupal\search_api_opensearch\SearchAPI\Query\FacetParamBuilder
arguments: ['@logger.channel.search_api_opensearch']
search_api_opensearch.spell_check_builder:
class: Drupal\search_api_opensearch\SearchAPI\Query\SpellCheckBuilder
arguments: []
search_api_opensearch.query_param_builder:
class: Drupal\search_api_opensearch\SearchAPI\Query\QueryParamBuilder
arguments:
......@@ -41,6 +44,7 @@ services:
- '@search_api_opensearch.search_param_builder'
- '@search_api_opensearch.more_like_this_param_builder'
- '@search_api_opensearch.facet_builder'
- '@search_api_opensearch.spell_check_builder'
- '@event_dispatcher'
- '@logger.channel.search_api_opensearch'
search_api_opensearch.delete_param_builder:
......@@ -49,11 +53,15 @@ services:
search_api_opensearch.facet_result_parser:
class: Drupal\search_api_opensearch\SearchAPI\Query\FacetResultParser
arguments: ['@logger.channel.search_api_opensearch']
search_api_opensearch.spell_check_result_parser:
class: Drupal\search_api_opensearch\SearchAPI\Query\SpellCheckResultParser
arguments: []
search_api_opensearch.query_result_parser:
class: Drupal\search_api_opensearch\SearchAPI\Query\QueryResultParser
arguments:
- '@search_api.fields_helper'
- '@search_api_opensearch.facet_result_parser'
- '@search_api_opensearch.spell_check_result_parser'
search_api_opensearch.field_mapper:
class: Drupal\search_api_opensearch\SearchAPI\FieldMapper
......
......@@ -19,7 +19,7 @@ abstract class BaseParamsEvent extends Event {
*/
public function __construct(
protected string $indexName,
protected array $params
protected array $params,
) {
}
......
......@@ -20,7 +20,7 @@ class FieldMappingEvent extends Event {
*/
public function __construct(
protected FieldInterface $field,
protected array $param
protected array $param,
) {
}
......
......@@ -39,7 +39,7 @@ class StandardConnector extends PluginBase implements OpenSearchConnectorInterfa
array $configuration,
$plugin_id,
$plugin_definition,
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
......
......@@ -83,7 +83,7 @@ class OpenSearchBackend extends BackendPluginBase implements PluginFormInterface
array $plugin_definition,
ConnectorPluginManager $connectorPluginManager,
BackendClientFactory $sapiClientFactory,
protected EventDispatcherInterface $eventDispatcher
protected EventDispatcherInterface $eventDispatcher,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->connectorPluginManager = $connectorPluginManager;
......@@ -112,6 +112,7 @@ class OpenSearchBackend extends BackendPluginBase implements PluginFormInterface
'search_api_facets',
'search_api_facets_operator_or',
'search_api_mlt',
'search_api_spellcheck',
];
}
......
<?php
namespace Drupal\search_api_opensearch\Plugin\search_api\data_type;
use Drupal\search_api\Plugin\search_api\data_type\TextDataType;
/**
* Provides data type to feed the suggester component.
*
* @SearchApiDataType(
* id = "search_api_opensearch_text_spellcheck",
* label = @Translation("Open Search Spellcheck"),
* description = @Translation("Full text field to feed the spellcheck component."),
* fallback_type = "text"
* )
*/
class SpellcheckTextDataType extends TextDataType {}
......@@ -260,7 +260,7 @@ class BackendClient implements BackendClientInterface {
/**
* {@inheritdoc}
*/
public function clearIndex(IndexInterface $index, string $datasource_id = NULL): void {
public function clearIndex(IndexInterface $index, ?string $datasource_id = NULL): void {
$this->removeIndex($index);
$this->addIndex($index);
}
......
......@@ -49,7 +49,7 @@ class BackendClientFactory {
protected FieldMapper $fieldParamsBuilder,
protected LoggerInterface $logger,
protected AnalyserManager $analyserManager,
protected EventDispatcherInterface $eventDispatcher
protected EventDispatcherInterface $eventDispatcher,
) {
}
......
......@@ -115,7 +115,7 @@ interface BackendClientInterface {
* @throws \Drupal\search_api\SearchApiException
* Thrown if an error occurred while trying to delete indexed items.
*/
public function clearIndex(IndexInterface $index, string $datasource_id = NULL): void;
public function clearIndex(IndexInterface $index, ?string $datasource_id = NULL): void;
/**
* Checks if an index exists on the server.
......
......@@ -17,7 +17,7 @@ class DeleteParamBuilder {
* The event dispatcher.
*/
public function __construct(
protected EventDispatcherInterface $eventDispatcher
protected EventDispatcherInterface $eventDispatcher,
) {
}
......
......@@ -25,7 +25,7 @@ class FieldMapper {
*/
public function __construct(
protected FieldsHelperInterface $fieldsHelper,
protected EventDispatcherInterface $eventDispatcher
protected EventDispatcherInterface $eventDispatcher,
) {
}
......
......@@ -25,7 +25,7 @@ class IndexParamBuilder {
*/
public function __construct(
protected FieldsHelperInterface $fieldsHelper,
protected EventDispatcherInterface $eventDispatcher
protected EventDispatcherInterface $eventDispatcher,
) {
}
......
......@@ -29,7 +29,7 @@ class MoreLikeThisParamBuilder {
*/
public function __construct(
protected EntityTypeManagerInterface $entityTypeManager,
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {
}
......
......@@ -22,7 +22,7 @@ class FacetParamBuilder {
* The logger.
*/
public function __construct(
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {
}
......
......@@ -17,7 +17,7 @@ class FacetResultParser {
* The logger.
*/
public function __construct(
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {
}
......
......@@ -19,7 +19,7 @@ class FilterBuilder {
* The logger.
*/
public function __construct(
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {
}
......
......@@ -40,6 +40,8 @@ class QueryParamBuilder {
* The More Like This param builder.
* @param \Drupal\search_api_opensearch\SearchAPI\Query\FacetParamBuilder $facetBuilder
* The facet param builder.
* @param \Drupal\search_api_opensearch\SearchAPI\Query\SpellCheckBuilder $spellCheckBuilder
* The spell check query builder.
* @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher
* The event dispatcher.
* @param \Psr\Log\LoggerInterface $logger
......@@ -52,8 +54,9 @@ class QueryParamBuilder {
protected SearchParamBuilder $searchParamBuilder,
protected MoreLikeThisParamBuilder $mltParamBuilder,
protected FacetParamBuilder $facetBuilder,
protected SpellCheckBuilder $spellCheckBuilder,
protected EventDispatcherInterface $eventDispatcher,
protected LoggerInterface $logger
protected LoggerInterface $logger,
) {
}
......@@ -150,6 +153,14 @@ class QueryParamBuilder {
}
}
// Spellcheck.
if (!empty($query->getOption('search_api_spellcheck'))) {
$suggest = $this->spellCheckBuilder->setSpellCheckQuery($query);
if (!empty($suggest)) {
$body['suggest'] = $suggest;
}
}
$params['body'] = $body;
// Preserve the options for further manipulation if necessary.
$query->setOption('OpenSearchParams', $params);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment