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

Open
wants to merge 14 commits into
base: qa/2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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,7 @@ public function execute($request)
$culture = $this->context->user->getCulture();

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

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

foreach ($items as $item) {
$search = new \Elastica\Search($client);
$search->addIndex($index)->addType($index->getType($item['type']));
foreach ($indices as $type => $index) {
$itemType = QubitSearch::getInstance()::ES_TYPE;

// This can be updated in ES 7.x when type params are optional
$search->addIndex($index)->addType($index->getType($itemType));
}

$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