Skip to content

Commit

Permalink
ES 6.x Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
melaniekung committed Jan 9, 2025
1 parent 5b9bac7 commit 44f03d7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function execute($request)
$queryBool = new \Elastica\Query\BoolQuery();

// Match in autocomplete
$queryText = new \Elastica\Query\Match();
$queryText = new \Elastica\Query\MatchQuery();
$queryText->setFieldQuery($item['field'].'.autocomplete', $this->queryString);
$queryBool->addMust($queryText);

Expand Down
4 changes: 3 additions & 1 deletion lib/job/arUpdateEsActorRelationsJob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ public static function updateActorRelationships($actor)
public static function previousRelationActorIds($actorId)
{
try {
// Dummy type is needed for ES 6, this should be updated in ES 7.x when type is not required for getDocument()
$esType = QubitSearch::getInstance()->getEsType();
// Get actor's previously indexed relations from Elasticsearch
$doc = QubitSearch::getInstance()->index->getIndex('QubitActor')->getDocument($actorId);
$doc = QubitSearch::getInstance()->index->getIndex('QubitActor')->getType($esType)->getDocument($actorId);

return self::uniqueIdsFromRelationData($doc->getData()['actorRelations']);
} catch (\Elastica\Exception\NotFoundException $e) {
Expand Down
6 changes: 3 additions & 3 deletions lib/model/QubitInformationObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2171,14 +2171,14 @@ public static function getByTitleIdentifierAndRepo($identifier, $title, $repoNam
$queryBool = new \Elastica\Query\BoolQuery();

// Use match query for exact matches.
$queryText = new \Elastica\Query\Match();
$queryText = new \Elastica\Query\MatchQuery();
$queryBool->addMust($queryText->setFieldQuery('identifier', $identifier));

$queryText = new \Elastica\Query\Match();
$queryText = new \Elastica\Query\MatchQuery();
$queryBool->addMust($queryText->setFieldQuery(sprintf('i18n.%s.title.untouched', $currentCulture), $title));

if (null !== $repoName) {
$queryText = new \Elastica\Query\Match();
$queryText = new \Elastica\Query\MatchQuery();
$queryBool->addMust($queryText->setFieldQuery(sprintf('repository.i18n.%s.authorizedFormOfName.untouched', $currentCulture), $repoName));
}

Expand Down
6 changes: 4 additions & 2 deletions lib/task/search/arDocumentTask.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public function execute($arguments = [], $options = [])
{
parent::execute($arguments, $options);

if (null !== $slugObject = QubitObject::getBySlug($arguments[slug])) {
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->getIndex($slugObject->className)->getDocument($slugObject->id);
// Dummy type is needed for ES 6, this should be updated in ES 7.x when type is not required for getDocument()
$esType = QubitSearch::getInstance()->getEsType();
$doc = QubitSearch::getInstance()->index->getIndex($slugObject->className)->getType($esType)->getDocument($slugObject->id);

echo json_encode($doc->getData(), JSON_PRETTY_PRINT)."\n";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,11 @@ public static function modelClassFromQubitObjectClass($className)
return str_replace('Qubit', 'arElasticSearch', $className);
}

public function getEsType()
{
return self::ES_TYPE;
}

/**
* Initialize indices wrapper.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function addAggFilters($aggs, $params)
if ('collection' == $param) {
$collection = QubitInformationObject::getById($value);

$querySelf = new \Elastica\Query\Match();
$querySelf = new \Elastica\Query\MatchQuery();
$querySelf->setFieldQuery('slug', $collection->slug);

$queryBool = new \Elastica\Query\BoolQuery();
Expand Down

0 comments on commit 44f03d7

Please sign in to comment.