Skip to content

Commit

Permalink
Rename and add more query classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
melaniekung committed Jun 4, 2024
1 parent a7d83bc commit 9bf3cee
Show file tree
Hide file tree
Showing 16 changed files with 1,495 additions and 23 deletions.
41 changes: 41 additions & 0 deletions plugins/arSolrPlugin/lib/arSolrAggregationFilter.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Access to Memory (AtoM) software.
*
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Access to Memory (AtoM) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>.
*/

/**
* arSolrAggregationFilter.
*/
class arSolrAggregationFilter extends arSolrQuery
{
public function __construct(string $name, $filter = null)
{
if (null !== $filter) {
$this->setFilter($filter);
}
}

/**
* Set the filter for this aggregation.
*
* @return $this
*/
public function setFilter(arSolrTermQuery $filter): self
{
return $this->setParam('filter', $filter);
}
}
36 changes: 36 additions & 0 deletions plugins/arSolrPlugin/lib/arSolrAggregationTerms.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/*
* This file is part of the Access to Memory (AtoM) software.
*
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Access to Memory (AtoM) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>.
*/

/**
* arSolrAggregationTerms.
*/
class arSolrAggregationTerms extends arSolrQuery
{
/**
* Set the field for this aggregation.
*
* @param string $field the name of the document field on which to perform this aggregation
*
* @return $this
*/
public function setField(string $field): self
{
return $this->setParam('field', $field);
}
}
12 changes: 11 additions & 1 deletion plugins/arSolrPlugin/lib/arSolrBoolQuery.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
*/
class arSolrBoolQuery extends arSolrQuery
{
public $queryBool;

/**
* Constructor.
*/
public function __construct()
{
$this->queryBool = $this->setRawQuery();
}

/**
* Add should part to query.
*
Expand All @@ -43,7 +53,7 @@ public function addShould($args): self
*/
public function addMust($args): self
{
return $this->_addQuery('must', $args);
return $this->_addQuery('must', (array) $args);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

/**
* arSolrExists.
* arSolrExistsQuery.
*/
class arSolrExists extends arSolrQuery
class arSolrExistsQuery extends arSolrQuery
{
/**
* Construct exists query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

/**
* arSolrMatchAll.
* arSolrMatchAllQuery.
*/
class arSolrMatchAll extends arSolrQuery
class arSolrMatchAllQuery extends arSolrQuery
{
/**
* Params.
Expand Down
116 changes: 116 additions & 0 deletions plugins/arSolrPlugin/lib/arSolrNestedQuery.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

/*
* This file is part of the Access to Memory (AtoM) software.
*
* Access to Memory (AtoM) is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Access to Memory (AtoM) is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Access to Memory (AtoM). If not, see <http://www.gnu.org/licenses/>.
*/

/**
* arSolrNestedQuery.
*/
class arSolrNestedQuery extends arSolrQuery
{
public $query;

/**
* Constructor.
*/
public function __construct()
{
$this->query = $this->setRawQuery();
}

/**
* Adds field to mlt query.
*
* @param string $path Nested object path
*
* @return $this
*/
public function setPath(string $path): self
{
return $this->setParam('path', $path);
}

/**
* Sets nested query.
*
* @return $this
*/
public function setQuery($query): self
{
return $this->setParam('query', $query);
}

/**
* Set score method.
*
* @param string $scoreMode options: avg, total, max and none
*
* @return $this
*/
public function setScoreMode(string $scoreMode = 'avg'): self
{
return $this->setParam('score_mode', $scoreMode);
}

/**
*
*
* @param string $
*
* @return $this
*/
public function addSort()
{
return;
}

/**
*
*
* @param string $
*
* @return $this
*/
public function setSort()
{
return;
}

/**
*
*
* @param string $
*
* @return $this
*/
public function setTerm()
{
return;
}

/**
*
*
* @param string $
*
* @return $this
*/
public function setFilter()
{
return;
}
}
2 changes: 1 addition & 1 deletion plugins/arSolrPlugin/lib/arSolrPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ private function setType($type)
return $type;
}

private function getFieldQuery($field, $type, $multiValue, $includeInCopy = true, $stored = true)
private function getFieldQuery($field, $type, $multiValue, $stored = true, $includeInCopy = true)
{
$stored = $stored ? 'true' : 'false';
$multiValue = $multiValue ? 'true' : 'false';
Expand Down
Loading

0 comments on commit 9bf3cee

Please sign in to comment.