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 dependencies #1876

Closed
wants to merge 5 commits into from
Closed
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
18 changes: 9 additions & 9 deletions apps/qubit/modules/actor/actions/browseAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
class ActorBrowseAction extends DefaultBrowseAction
{
public const INDEX_TYPE = 'QubitActor';
public const INDEX_TYPE = 'qubitactor';

// Arrays not allowed in class constants
public static $NAMES = [
Expand All @@ -39,13 +39,13 @@ class ActorBrowseAction extends DefaultBrowseAction
];
public static $FILTERTAGS = [
'hasDigitalObject' => [],
'repository' => ['model' => 'QubitRepository'],
'entityType' => ['model' => 'QubitTerm'],
'relatedType' => ['model' => 'QubitTerm'],
'occupation' => ['model' => 'QubitTerm'],
'place' => ['model' => 'QubitTerm'],
'subject' => ['model' => 'QubitTerm'],
'mediatypes' => ['model' => 'QubitTerm'],
'repository' => ['model' => 'qubitrepository'],
'entityType' => ['model' => 'qubitterm'],
'relatedType' => ['model' => 'qubitterm'],
'occupation' => ['model' => 'qubitterm'],
'place' => ['model' => 'qubitterm'],
'subject' => ['model' => 'qubitterm'],
'mediatypes' => ['model' => 'qubitterm'],
'emptyField' => [],
];
public static $AGGS = [
Expand Down 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['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['qubitinformationobject']->search($query);
}

public static function nestedActorAndEventTypeQuery($actorId, $eventTypeId)
Expand Down
8 changes: 4 additions & 4 deletions apps/qubit/modules/clipboard/actions/viewAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function execute($request)

// Get entity type and class name
$this->type = $request->getGetParameter('type', 'informationObject');
$this->entityType = 'Qubit'.ucfirst($this->type);
$this->entityType = 'qubit'.strtolower($this->type);

$slugs = $request->getPostParameter('slugs', []);

Expand All @@ -45,13 +45,13 @@ public function execute($request)
$this->setSortOptions();
$this->setESSort($request);

if ('QubitInformationObject' == $this->entityType) {
if ('qubitinformationobject' == $this->entityType) {
QubitAclSearch::filterDrafts($this->search->queryBool);
}

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

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

// Page results
Expand Down Expand Up @@ -88,7 +88,7 @@ private function setSortOptions()
}

// IO specific sort options
if ('QubitInformationObject' === $this->entityType) {
if ('qubitinformationobject' === $this->entityType) {
$this->sortOptions['alphabetic'] = $this->context->i18n->__('Title');
$this->sortOptions['referenceCode'] = $this->context->i18n->__('Reference code');
$this->sortOptions['startDate'] = $this->context->i18n->__('Start date');
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[$this::INDEX_TYPE]->search($this->search->query);

$count = $resultSetWithoutLanguageFilter->getTotalHits();
}
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['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['qubitterm']->search($this->query);
}

// Page results
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['qubitinformationobject']->search($this->query);

// Page results
$this->pager = new QubitSearchPager($resultSet);
Expand Down
26 changes: 13 additions & 13 deletions apps/qubit/modules/informationobject/actions/browseAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class InformationObjectBrowseAction extends DefaultBrowseAction
{
public const INDEX_TYPE = 'QubitInformationObject';
public const INDEX_TYPE = 'qubitinformationobject';

// Arrays not allowed in class constants
public static $NAMES = [
Expand All @@ -40,21 +40,21 @@ class InformationObjectBrowseAction extends DefaultBrowseAction
'findingAidStatus',
];
public static $FILTERTAGS = [
'repos' => ['model' => 'QubitRepository'],
'collection' => ['model' => 'QubitInformationObject'],
'creators' => ['model' => 'QubitActor'],
'names' => ['model' => 'QubitActor'],
'places' => ['model' => 'QubitTerm'],
'levels' => ['model' => 'QubitTerm'],
'subjects' => ['model' => 'QubitTerm'],
'mediatypes' => ['model' => 'QubitTerm'],
'copyrightStatus' => ['model' => 'QubitTerm'],
'materialType' => ['model' => 'QubitTerm'],
'repos' => ['model' => 'qubitrepository'],
'collection' => ['model' => 'qubitinformationobject'],
'creators' => ['model' => 'qubitactor'],
'names' => ['model' => 'qubitactor'],
'places' => ['model' => 'qubitterm'],
'levels' => ['model' => 'qubitterm'],
'subjects' => ['model' => 'qubitterm'],
'mediatypes' => ['model' => 'qubitterm'],
'copyrightStatus' => ['model' => 'qubitterm'],
'materialType' => ['model' => 'qubitterm'],
'onlyMedia' => [],
'languages' => [],
'dateRange' => ['params' => ['startDate', 'endDate'], 'operator' => 'or'],
'findingAidStatus' => [],
'ancestor' => ['model' => 'QubitInformationObject'],
'ancestor' => ['model' => 'qubitinformationobject'],
];
public static $AGGS = [
'languages' => [
Expand Down 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['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 @@ -174,6 +174,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['qubitinformationobject']->search($query);
}
}
6 changes: 3 additions & 3 deletions apps/qubit/modules/repository/actions/browseAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
class RepositoryBrowseAction extends DefaultBrowseAction
{
public const INDEX_TYPE = 'QubitRepository';
public const INDEX_TYPE = 'qubitrepository';

// Arrays not allowed in class constants
public static $AGGS = [
Expand Down 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['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['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['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['qubitactor']->search($query);
}
}
16 changes: 8 additions & 8 deletions apps/qubit/modules/search/actions/autocompleteAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,42 +39,42 @@ 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);

$items = [
[
'type' => 'QubitInformationObject',
'type' => 'qubitinformationobject',
'field' => sprintf('i18n.%s.title', $culture),
'fields' => ['slug', sprintf('i18n.%s.title', $culture), 'levelOfDescriptionId'],
],
[
'type' => 'QubitRepository',
'type' => 'qubitrepository',
'field' => sprintf('i18n.%s.authorizedFormOfName', $culture),
'fields' => ['slug', sprintf('i18n.%s.authorizedFormOfName', $culture)],
],
[
'type' => 'QubitActor',
'type' => 'qubitactor',
'field' => sprintf('i18n.%s.authorizedFormOfName', $culture),
'fields' => ['slug', sprintf('i18n.%s.authorizedFormOfName', $culture)],
],
[
'type' => 'QubitTerm',
'type' => 'qubitterm',
'field' => sprintf('i18n.%s.name', $culture),
'fields' => ['slug', sprintf('i18n.%s.name', $culture)],
'term_filter' => ['taxonomyId' => QubitTaxonomy::PLACE_ID],
],
[
'type' => 'QubitTerm',
'type' => 'qubitterm',
'field' => sprintf('i18n.%s.name', $culture),
'fields' => ['slug', sprintf('i18n.%s.name', $culture)],
'term_filter' => ['taxonomyId' => QubitTaxonomy::SUBJECT_ID],
],
];

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

Expand All @@ -93,7 +93,7 @@ public function execute($request)
$queryBool->addMust(new \Elastica\Query\Term($item['term_filter']));
}

if (isset($request->repos) && ctype_digit($request->repos) && 'QubitInformationObject' == $item['type']) {
if (isset($request->repos) && ctype_digit($request->repos) && 'qubitinformationobject' == $item['type']) {
$queryBool->addMust(new \Elastica\Query\Term(['repository.id' => $request->repos]));

// Store realm in user session
Expand All @@ -103,7 +103,7 @@ public function execute($request)
$this->context->user->removeAttribute('search-realm');
}

if ('QubitInformationObject' == $item['type']) {
if ('qubitinformationobject' == $item['type']) {
QubitAclSearch::filterDrafts($queryBool);
}

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[$this->form->getValue('className')]->search($query);

// Page results
$this->pager = new QubitSearchPager($resultSet);
Expand All @@ -201,11 +201,11 @@ protected function addField($name)
switch ($name) {
case 'className':
$choices = [
'QubitInformationObject' => sfConfig::get('app_ui_label_informationobject'),
'QubitActor' => sfConfig::get('app_ui_label_actor'),
'QubitRepository' => sfConfig::get('app_ui_label_repository'),
'QubitTerm' => sfConfig::get('app_ui_label_term'),
'QubitFunctionObject' => sfConfig::get('app_ui_label_function'),
'qubitinformationobject' => sfConfig::get('app_ui_label_informationobject'),
'qubitactor' => sfConfig::get('app_ui_label_actor'),
'qubitrepository' => sfConfig::get('app_ui_label_repository'),
'qubitterm' => sfConfig::get('app_ui_label_term'),
'qubitfunctionobject' => sfConfig::get('app_ui_label_function'),
];

$this->form->setValidator($name, new sfValidatorString());
Expand Down
4 changes: 2 additions & 2 deletions apps/qubit/modules/search/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// Notice that his is also used in XHR context (see treeview search)
class SearchIndexAction extends DefaultBrowseAction
{
public const INDEX_TYPE = 'QubitInformationObject';
public const INDEX_TYPE = 'qubitinformationobject';

public function execute($request)
{
Expand Down 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['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['qubitterm']->search($this->query);

// Return special response in JSON for XHR requests
if ($request->isXmlHttpRequest()) {
Expand Down
6 changes: 3 additions & 3 deletions apps/qubit/modules/term/actions/indexAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class TermIndexAction extends DefaultBrowseAction
{
public const INDEX_TYPE = 'QubitInformationObject';
public const INDEX_TYPE = 'qubitinformationobject';

// Arrays not allowed in class constants
public static $AGGS = [
Expand Down 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['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['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 @@ -58,11 +58,11 @@ public static function getEsDocsRelatedToTerm($relatedModelClass, $term, $option
$search->query->setQuery($search->queryBool->addMust($query));

// Filter out drafts if querying descriptions
if ('QubitInformationObject' == $relatedModelClass) {
if ('qubitinformationobject' == $relatedModelClass) {
QubitAclSearch::filterDrafts($search->queryBool);
}

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

public static function getEsDocsRelatedToTermCount($relatedModelClass, $termId, $search = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class TermRelatedAuthoritiesAction extends TermIndexAction
{
public const INDEX_TYPE = 'QubitActor';
public const INDEX_TYPE = 'qubitactor';

// Arrays not allowed in class constants
public static $FILTERTAGS = [];
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",
"jasig/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