Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ElasticSearch and Elastica to 6.x #1880

Merged
merged 35 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
81617d6
Update ElasticSearch and Elastica dependencies
anvit Oct 1, 2024
7c50884
Remove arElasticSearchIndexDecorator.
melaniekung Oct 3, 2024
1c5feeb
Update index for ES 6.x
anvit Oct 9, 2024
ec4e748
Fix autocompleteAction for ES 6.x
anvit Oct 9, 2024
a19f8e1
Add index types for ES Queries without a type
anvit Oct 9, 2024
90d1e08
Fix updateByQuery calls for ElasticSearch 6.x
anvit Oct 9, 2024
47cc1a9
Fix broken publication status update
anvit Oct 9, 2024
3adaac0
Fix linting errors
anvit Oct 9, 2024
5575f96
Switch elasticsearch to the oss docker image
anvit Oct 16, 2024
0259ed0
Update mapping condition for _all fields
anvit Nov 14, 2024
a13821d
Update ES mapping to copy relevant fields to _all
anvit Nov 18, 2024
3f0e4d6
Rename arElasticSearchIndexDecorator
anvit Nov 18, 2024
0e0d87d
Rename getType function from ESMultiIndexWrapper
anvit Nov 18, 2024
bc54543
Add dummy type for ES index
anvit Nov 19, 2024
9d6fa03
Change references to index type for ElasticSearch
anvit Nov 21, 2024
2ff7ea4
Fix copy to _all fields for ES mapping
anvit Nov 22, 2024
9adb350
Remove unnecessary ElasticSearch type variables
anvit Nov 22, 2024
fc6d069
Remove ES index prefix from MultiIndexWrapper
anvit Nov 22, 2024
c6f0c2a
Fix autocompleteAction bug, address CR feedback
anvit Nov 22, 2024
9859544
Remove non text fields from _all ES mapping
anvit Nov 22, 2024
ef14555
Remove unnecessary loop in arElasticSearchPlugin
anvit Nov 22, 2024
02b3c4b
Update ES index refresh to only refresh one index
anvit Nov 25, 2024
bf282c8
Refactor ES initialize and populate methods (WIP)
anvit Dec 3, 2024
1525e40
Tweak index recreation
jraddaoui Dec 4, 2024
5c04228
Initialize on populate
jraddaoui Dec 4, 2024
a66101a
Tweak flush/refresh operation
jraddaoui Dec 4, 2024
02c4631
Only ignore 404 errors when deleting indexes
jraddaoui Dec 4, 2024
ec56eec
Prevent flush if current index name is not set
jraddaoui Dec 4, 2024
285f12b
Make loadDiacriticsMappings a private function
jraddaoui Dec 4, 2024
5e7356f
Improve populate logging
jraddaoui Dec 4, 2024
7300691
Configure filters once before indices creation
jraddaoui Dec 4, 2024
945e8c0
Normalize loadDiacriticsMappings function
jraddaoui Dec 4, 2024
0efd43b
Create indices on update if they don't exist
jraddaoui Dec 4, 2024
404b5ce
Trust recreate option on index creation
jraddaoui Dec 4, 2024
cb1744c
Remove unused function
jraddaoui Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/qubit/modules/actor/actions/browseAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ protected function doSearch($request)

$this->search->query->setQuery($this->search->queryBool);

return QubitSearch::getInstance()->index->getType('QubitActor')->search($this->search->getQuery(false));
return QubitSearch::getInstance()->index->getIndex('QubitActor')->search($this->search->getQuery(false));
}

private function getRelatedAuthorityUsingSlug($slug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function getRelatedInformationObjects($actorId, $page, $limit, $ev
$query->setSize($limit);
$query->setFrom($limit * ($page - 1));

return QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
return QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($query);
}

public static function nestedActorAndEventTypeQuery($actorId, $eventTypeId)
Expand Down
2 changes: 1 addition & 1 deletion apps/qubit/modules/clipboard/actions/viewAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function execute($request)

$this->search->query->setQuery($this->search->queryBool);

$resultSet = QubitSearch::getInstance()->index->getType($this->entityType)->search($this->search->query);
$resultSet = QubitSearch::getInstance()->index->getIndex($this->entityType)->search($this->search->query);
}

// Page results
Expand Down
2 changes: 1 addition & 1 deletion apps/qubit/modules/default/actions/browseAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected function populateAggs($resultSet)

$this->search->query->setRawQuery($queryParams);

$resultSetWithoutLanguageFilter = QubitSearch::getInstance()->index->getType($this::INDEX_TYPE)->search($this->search->query);
$resultSetWithoutLanguageFilter = QubitSearch::getInstance()->index->getIndex($this::INDEX_TYPE)->search($this->search->query);

$count = $resultSetWithoutLanguageFilter->getTotalHits();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function doElasticsearchQuery($term, $options = [])
// Get results, with drafts filtered when appropriate
return QubitSearch::getInstance()
->index
->getType('QubitInformationObject')
->getIndex('QubitInformationObject')
->search($query->getQuery(false, false));
}

Expand Down Expand Up @@ -237,7 +237,7 @@ protected function countChildren($id, $options = [])
// Return a count of the results found
return QubitSearch::getInstance()
->index
->getType('QubitInformationObject')
->getIndex('QubitInformationObject')
->count($query->getQuery(false, false));
}

Expand Down
4 changes: 2 additions & 2 deletions apps/qubit/modules/default/actions/moveAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public function execute($request)
$this->query->setQuery($this->queryBool);

if ($this->resource instanceof QubitInformationObject) {
$resultSet = QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($this->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($this->query);
} elseif ($this->resource instanceof QubitTerm) {
// TODO: Add parent_id for terms in ES, add move button
$resultSet = QubitSearch::getInstance()->index->getType('QubitTerm')->search($this->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitTerm')->search($this->query);
}

// Page results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function getDescendantDigitalObjectCount()

$results = QubitSearch::getInstance()
->index
->getType('QubitInformationObject')
->getIndex('QubitInformationObject')
->search($search->getQuery(false, true));

return $results->getTotalHits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function execute($request)

$this->query->setQuery($this->queryBool);

$resultSet = QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($this->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($this->query);

// Page results
$this->pager = new QubitSearchPager($resultSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function execute($request)

$this->setView($request);

$resultSet = QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($this->search->getQuery(false, true));
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($this->search->getQuery(false, true));

// Page results
$this->pager = new QubitSearchPager($resultSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,6 @@ private static function getResults($resource, $limit = 10, $page = 1, $sort = nu
QubitAclSearch::filterDrafts($queryBool);
$query->setQuery($queryBool);

return QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
return QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($query);
}
}
4 changes: 2 additions & 2 deletions apps/qubit/modules/repository/actions/browseAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function execute($request)

$this->search->query->setQuery($this->search->queryBool);

$resultSet = QubitSearch::getInstance()->index->getType('QubitRepository')->search($this->search->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitRepository')->search($this->search->query);

$this->pager = new QubitSearchPager($resultSet);
$this->pager->setPage($request->page ? $request->page : 1);
Expand Down Expand Up @@ -201,7 +201,7 @@ private function getAdvancedFilterTerms()
$query = new \Elastica\Query(new \Elastica\Query\MatchAll());
$query->setSize($limit);

$this->repositories = QubitSearch::getInstance()->index->getType('QubitRepository')->search($query);
$this->repositories = QubitSearch::getInstance()->index->getIndex('QubitRepository')->search($query);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ public static function getHoldings($id, $page, $limit)
$title = sprintf('i18n.%s.title.alphasort', sfContext::getInstance()->user->getCulture());
$query->setSort([$title => 'asc']);

return QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
return QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public static function getActors($repositoryId, $page, $limit)
$field = sprintf('i18n.%s.authorizedFormOfName.alphasort', sfContext::getInstance()->user->getCulture());
$query->setSort([$field => 'asc']);

return QubitSearch::getInstance()->index->getType('QubitActor')->search($query);
return QubitSearch::getInstance()->index->getIndex('QubitActor')->search($query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function execute($request)
$culture = $this->context->user->getCulture();

$client = QubitSearch::getInstance()->client;
$index = QubitSearch::getInstance()->index->getInstance();

// Multisearch object
$mSearch = new \Elastica\Multi\Search($client);
Expand Down Expand Up @@ -74,9 +73,12 @@ public function execute($request)
],
];

// Wrapper to access ElasticSearch indices
$indexWrapper = QubitSearch::getInstance()->index;

foreach ($items as $item) {
$search = new \Elastica\Search($client);
$search->addIndex($index)->addType($index->getType($item['type']));
$search->addIndex($indexWrapper->getIndex($item['type']));

$query = new \Elastica\Query();
$query->setSize(3)->setSource($item['fields']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function doSearch()
$query->setFrom($limit * ($page - 1));
$query->setSort(['createdAt' => 'desc']);

$resultSet = QubitSearch::getInstance()->index->getType($this->form->getValue('className'))->search($query);
$resultSet = QubitSearch::getInstance()->index->getIndex($this->form->getValue('className'))->search($query);

// Page results
$this->pager = new QubitSearchPager($resultSet);
Expand Down
2 changes: 1 addition & 1 deletion apps/qubit/modules/search/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function execute($request)
QubitAclSearch::filterDrafts($this->search->queryBool);
$this->search->query->setQuery($this->search->queryBool);

$resultSet = QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($this->search->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($this->search->query);

$total = $resultSet->getTotalHits();
if (1 > $total) {
Expand Down
2 changes: 1 addition & 1 deletion apps/qubit/modules/taxonomy/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function execute($request)
$this->query->setSort(['updatedAt' => $request->sortDir]);
}

$resultSet = QubitSearch::getInstance()->index->getType('QubitTerm')->search($this->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitTerm')->search($this->query);

// Return special response in JSON for XHR requests
if ($request->isXmlHttpRequest()) {
Expand Down
4 changes: 2 additions & 2 deletions apps/qubit/modules/term/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function execute($request)
QubitAclSearch::filterDrafts($this->search->queryBool);
$this->search->query->setQuery($this->search->queryBool);

$resultSet = QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($this->search->query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($this->search->query);

// Page results
$this->pager = new QubitSearchPager($resultSet);
Expand Down Expand Up @@ -328,7 +328,7 @@ protected function loadListTerms($request)
$listQueryBool->addMust(new \Elastica\Query\Term(['taxonomyId' => $this->resource->taxonomyId]));

$listQuery->setQuery($listQueryBool);
$this->listResultSet = QubitSearch::getInstance()->index->getType('QubitTerm')->search($listQuery);
$this->listResultSet = QubitSearch::getInstance()->index->getIndex('QubitTerm')->search($listQuery);

// Page list results
$this->listPager = new QubitSearchPager($this->listResultSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function getEsDocsRelatedToTerm($relatedModelClass, $term, $option
QubitAclSearch::filterDrafts($search->queryBool);
}

return QubitSearch::getInstance()->index->getType($relatedModelClass)->search($search->getQuery(false));
return QubitSearch::getInstance()->index->getIndex($relatedModelClass)->search($search->getQuery(false));
}

public static function getEsDocsRelatedToTermCount($relatedModelClass, $termId, $search = null)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"league/csv": "^9.4",
"apereo/phpcas": "^1.3.8",
"ezyang/htmlpurifier": "^4.13",
"ruflin/elastica": "5.*",
"ruflin/elastica": "6.*",
"jumbojett/openid-connect-php": "^1.0"
},
"autoload-dev": {
Expand Down
Loading
Loading