Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
elasticsearch_connector
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
elasticsearch_connector
Commits
78406cd9
Commit
78406cd9
authored
Jul 22, 2019
by
Yuriy Gerasimov
Committed by
Nikolay Ignatov
Jul 22, 2019
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3065334
by ygerasimov: Remove hardcoded IndexFactory
parent
5c2cc5f6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ElasticSearch/Parameters/Builder/SearchBuilder.php
+8
-4
8 additions, 4 deletions
src/ElasticSearch/Parameters/Builder/SearchBuilder.php
src/ElasticSearch/Parameters/Factory/IndexFactory.php
+4
-4
4 additions, 4 deletions
src/ElasticSearch/Parameters/Factory/IndexFactory.php
with
12 additions
and
8 deletions
src/ElasticSearch/Parameters/Builder/SearchBuilder.php
+
8
−
4
View file @
78406cd9
...
...
@@ -6,7 +6,6 @@ use Drupal\Component\Utility\Html;
use
Drupal\Component\Utility\Unicode
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Drupal\elasticsearch_connector
\ElasticSearch\Parameters\Factory\FilterFactory
;
use
Drupal\elasticsearch_connector
\ElasticSearch\Parameters\Factory\IndexFactory
;
use
Drupal\search_api
\ParseMode\ParseModeInterface
;
use
Drupal\search_api
\Query\Condition
;
use
Drupal\search_api
\Query\ConditionGroupInterface
;
...
...
@@ -68,7 +67,9 @@ class SearchBuilder {
*/
public
function
build
()
{
// Query options.
$params
=
IndexFactory
::
index
(
$this
->
index
,
TRUE
);
$indexFactory
=
\Drupal
::
service
(
'elasticsearch_connector.index_factory'
);
$params
=
$indexFactory
->
index
(
$this
->
index
,
TRUE
);
$query_options
=
$this
->
getSearchQueryOptions
();
// Set the size and from parameters.
...
...
@@ -125,7 +126,8 @@ class SearchBuilder {
$this
->
query
->
setOption
(
'ElasticParams'
,
$params
);
// Allow other modules to alter index config before we create it.
$indexName
=
IndexFactory
::
getIndexName
(
$this
->
index
);
$indexFactory
=
\Drupal
::
service
(
'elasticsearch_connector.index_factory'
);
$indexName
=
$indexFactory
->
getIndexName
(
$this
->
index
);
$dispatcher
=
\Drupal
::
service
(
'event_dispatcher'
);
$buildSearchParamsEvent
=
new
BuildSearchParamsEvent
(
$params
,
$indexName
);
$event
=
$dispatcher
->
dispatch
(
BuildSearchParamsEvent
::
BUILD_QUERY
,
$buildSearchParamsEvent
);
...
...
@@ -259,7 +261,9 @@ class SearchBuilder {
];
// Allow other modules to alter index config before we create it.
$indexName
=
IndexFactory
::
getIndexName
(
$this
->
index
);
$indexFactory
=
\Drupal
::
service
(
'elasticsearch_connector.index_factory'
);
$indexName
=
$indexFactory
->
getIndexName
(
$this
->
index
);
$dispatcher
=
\Drupal
::
service
(
'event_dispatcher'
);
$prepareSearchQueryEvent
=
new
PrepareSearchQueryEvent
(
$elasticSearchQuery
,
$indexName
);
$event
=
$dispatcher
->
dispatch
(
PrepareSearchQueryEvent
::
PREPARE_QUERY
,
$prepareSearchQueryEvent
);
...
...
This diff is collapsed.
Click to expand it.
src/ElasticSearch/Parameters/Factory/IndexFactory.php
+
4
−
4
View file @
78406cd9
...
...
@@ -37,7 +37,7 @@ class IndexFactory {
*/
public
static
function
index
(
IndexInterface
$index
,
$with_type
=
FALSE
)
{
$params
=
[];
$params
[
'index'
]
=
IndexFactory
::
getIndexName
(
$index
);
$params
[
'index'
]
=
static
::
getIndexName
(
$index
);
if
(
$with_type
)
{
$params
[
'type'
]
=
$index
->
id
();
...
...
@@ -55,7 +55,7 @@ class IndexFactory {
* @return array
*/
public
static
function
create
(
IndexInterface
$index
)
{
$indexName
=
IndexFactory
::
getIndexName
(
$index
);
$indexName
=
static
::
getIndexName
(
$index
);
$indexConfig
=
[
'index'
=>
$indexName
,
'body'
=>
[
...
...
@@ -111,7 +111,7 @@ class IndexFactory {
* index.
*/
public
static
function
bulkIndex
(
IndexInterface
$index
,
array
$items
)
{
$params
=
IndexFactory
::
index
(
$index
,
TRUE
);
$params
=
static
::
index
(
$index
,
TRUE
);
foreach
(
$items
as
$id
=>
$item
)
{
$data
=
[
...
...
@@ -172,7 +172,7 @@ class IndexFactory {
* Parameters required to create an index mapping.
*/
public
static
function
mapping
(
IndexInterface
$index
)
{
$params
=
IndexFactory
::
index
(
$index
,
TRUE
);
$params
=
static
::
index
(
$index
,
TRUE
);
$properties
=
[
'id'
=>
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment