Skip to content

Commit

Permalink
Rename getType function from ESMultiIndexWrapper
Browse files Browse the repository at this point in the history
Rename getType from arElasticSearchMultiIndexWrapper to getIndex for
clarity.
  • Loading branch information
anvit committed Nov 19, 2024
1 parent 3f0e4d6 commit 0e0d87d
Show file tree
Hide file tree
Showing 36 changed files with 52 additions and 47 deletions.
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 @@ -77,7 +77,10 @@ public function execute($request)
foreach ($items as $item) {
$search = new \Elastica\Search($client);
foreach ($indices as $type => $index) {
$itemType = QubitSearch::getInstance()->index->getIndexTypeName($item['type']);
$itemType = QubitSearch::getInstance()->index->getIndexName($item['type']);

// This will need to be updated in ES 7.x if it is updated to a dummy type,
// and then removed in ES 8.x when types are no longer required.
$search->addIndex($index)->addType($index->getType($itemType));
}

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
6 changes: 3 additions & 3 deletions lib/QubitLftSyncer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function getChildLftChecksumForElasticsearch()
// Get results
$result = QubitSearch::getInstance()
->index
->getType('QubitInformationObject')
->getIndex('QubitInformationObject')
->search($query->getQuery(false, false));

// Amalgamate lft values in array
Expand All @@ -93,8 +93,8 @@ private function repairEsChildrenLftValues()

$bulk = new Elastica\Bulk(QubitSearch::getInstance()->client);
$type = 'QubitInformationObject';
$bulk->setIndex(QubitSearch::getInstance()->index->getType($type)->getName());
$bulk->setType(QubitSearch::getInstance()->index->getIndexTypeName($type));
$bulk->setIndex(QubitSearch::getInstance()->index->getIndex($type)->getName());
$bulk->setType(QubitSearch::getInstance()->index->getIndexName($type));

foreach ($results as $row) {
$bulk->addAction(
Expand Down
2 changes: 1 addition & 1 deletion lib/job/arActorExportJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function findExportRecords($parameters)

return QubitSearch::getInstance()
->index
->getType('QubitActor')
->getIndex('QubitActor')
->createSearch($query->getQuery(false, false));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/job/arInformationObjectExportJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function findExportRecords($parameters)

return QubitSearch::getInstance()
->index
->getType('QubitInformationObject')
->getIndex('QubitInformationObject')
->createSearch($query->getQuery(false, false));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/job/arRepositoryCsvExportJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function exportResults($path)
{
$itemsExported = 0;

$search = QubitSearch::getInstance()->index->getType('QubitRepository')->createSearch($this->search->getQuery(false, false));
$search = QubitSearch::getInstance()->index->getIndex('QubitRepository')->createSearch($this->search->getQuery(false, false));

$writer = new csvRepositoryExport($path, null, 10000);
$writer->loadResourceSpecificConfiguration('QubitRepository');
Expand Down
2 changes: 1 addition & 1 deletion lib/job/arUpdateEsActorRelationsJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function previousRelationActorIds($actorId)
{
try {
// Get actor's previously indexed relations from Elasticsearch
$doc = QubitSearch::getInstance()->index->getType('QubitActor')->getDocument($actorId);
$doc = QubitSearch::getInstance()->index->getIndex('QubitActor')->getDocument($actorId);

return self::uniqueIdsFromRelationData($doc->getData()['actorRelations']);
} catch (\Elastica\Exception\NotFoundException $e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/job/arUpdatePublicationStatusJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function runJob($parameters)
];

$type = 'QubitInformationObject';
$response = QubitSearch::getInstance()->index->getType($type)->updateByQuery($query, $queryScript, $options)->getData();
$response = QubitSearch::getInstance()->index->getIndex($type)->updateByQuery($query, $queryScript, $options)->getData();

$message = $this->i18n->__(
'Index update completed in %1 ms.',
Expand Down
2 changes: 1 addition & 1 deletion lib/model/QubitInformationObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ public static function getByTitleIdentifierAndRepo($identifier, $title, $repoNam

$query = new \Elastica\Query($queryBool);
$query->setSize(1);
$resultSet = QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
$resultSet = QubitSearch::getInstance()->index->getIndex('QubitInformationObject')->search($query);

if ($resultSet->count()) {
return $resultSet[0]->getId();
Expand Down
2 changes: 1 addition & 1 deletion lib/model/QubitTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ public static function getEsTermsByTaxonomyId($taxonomyId, $limit = 10)
$query = new \Elastica\Query($queryBool);
$query->setSize($limit);

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

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/task/propel/propelGenerateSlugsTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private function getSlugStringFromES($id, $property)
$query->setQuery($queryBool);
$query->setSize(1);

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

if (!$results->count()) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/task/search/arDocumentTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function execute($arguments = [], $options = [])
if (null !== $slugObject = QubitObject::getBySlug($arguments[slug])) {
$this->log(sprintf("Fetching data for %s ID %d...\n", $slugObject->className, $slugObject->id));

$doc = QubitSearch::getInstance()->index->getType($slugObject->className)->getDocument($slugObject->id);
$doc = QubitSearch::getInstance()->index->getIndex($slugObject->className)->getDocument($slugObject->id);

echo json_encode($doc->getData(), JSON_PRETTY_PRINT)."\n";
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/task/search/arSearchStatusTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function objectsIndexed($docType)
// Determine model class name from document type name
$docTypeModelClass = 'Qubit'.ucfirst($docType);

return QubitSearch::getInstance()->index->getType($docTypeModelClass)->count();
return QubitSearch::getInstance()->index->getIndex($docTypeModelClass)->count();
}

private function objectsAvailableToIndex($docType)
Expand Down
2 changes: 1 addition & 1 deletion lib/task/tools/updatePublicationStatusTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function updatePublicationStatusDescendants($resource, $publicationSta
$options = ['conflicts' => 'proceed'];

$type = 'QubitInformationObject';
$response = QubitSearch::getInstance()->index->getType($type)->updateByQuery($query, $queryScript, $options)->getData();
$response = QubitSearch::getInstance()->index->getIndex($type)->updateByQuery($query, $queryScript, $options)->getData();

if (!empty($response['failures'])) {
$this->failures += count($response['failures']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public function refresh()
}
}

public function getType($name)
// Return the index element from the array of indices
// that matches the qualified index name
public function getIndex($name)
{
$name = $this->getIndexName($name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function populate($options = [])
// If excluding types then index as a whole hasn't been flushed: delete
// type's documents if not updating
if (count($excludeTypes) && !$update) {
$this->index->getType('Qubit'.$camelizedTypeName)->deleteByQuery(new \Elastica\Query\MatchAll());
$this->index->getIndex('Qubit'.$camelizedTypeName)->deleteByQuery(new \Elastica\Query\MatchAll());
}

$class = new $className();
Expand Down Expand Up @@ -370,7 +370,7 @@ public function addDocument($data, $type)
$this->index->refresh();
}
} else {
$this->index->getType($type)->addDocuments([$document]);
$this->index->getIndex($type)->addDocuments([$document]);
}
}

Expand Down Expand Up @@ -400,7 +400,7 @@ public function partialUpdate($object, $data)
$document->setType($this->index->getIndexName($type));

try {
$this->index->getType($type)->updateDocuments([$document]);
$this->index->getIndex($type)->updateDocuments([$document]);
} catch (\Elastica\Exception\NotFoundException $e) {
// Create document if it's not found
$this->update($object);
Expand All @@ -420,7 +420,7 @@ public function partialUpdateById(string $className, int $id, array $data)
$document = new \Elastica\Document($id, $data);

try {
$this->index->getType($className)->updateDocuments([$document]);
$this->index->getIndex($className)->updateDocuments([$document]);
} catch (\Elastica\Exception\ResponseException $e) {
// Create document if none exists
$modelPdoClassName = self::modelClassFromQubitObjectClass($className).'Pdo';
Expand Down Expand Up @@ -473,7 +473,7 @@ public function delete($object)
}
} else {
try {
$this->index->getType($type)->deleteById($object->id);
$this->index->getIndex($type)->deleteById($object->id);
} catch (\Elastica\Exception\NotFoundException $e) {
// Ignore
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function get($request)

$this->search->query->setSort([$field => $order]);

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

// Build array from results
$results = $lodMapping = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function execute($request)
break;
}

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

$this->pager = new QubitSearchPager($resultSet);
$this->pager->setPage($request->page ? $request->page : 1);
Expand Down
Loading

0 comments on commit 0e0d87d

Please sign in to comment.