From bbafb783abe834236e02968a28085bff236b6d6a Mon Sep 17 00:00:00 2001 From: Anvit Srivastav Date: Wed, 10 Jul 2024 11:40:38 -0700 Subject: [PATCH] Update arSolrExistsQuery and add functionality Add lucene based existence query for arSolrExistsQuery --- .../lib/query/arSolrExistsQuery.class.php | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/plugins/arSolrPlugin/lib/query/arSolrExistsQuery.class.php b/plugins/arSolrPlugin/lib/query/arSolrExistsQuery.class.php index e640f51ee4..c2a76007b1 100644 --- a/plugins/arSolrPlugin/lib/query/arSolrExistsQuery.class.php +++ b/plugins/arSolrPlugin/lib/query/arSolrExistsQuery.class.php @@ -19,5 +19,63 @@ class arSolrExistsQuery extends arSolrAbstractQuery { - // TODO + /** + * Query Params. + * + * @var mixed + */ + protected $query; + + /** + * Field to be queried. + * + * @var string + */ + protected $field; + + /** + * Constructor. + * + * @param string $field + */ + public function __construct($field) + { + $this->setField($field); + $this->generateQueryParams(); + } + + public function setField($field) + { + $this->field = $field; + } + + public function getField() + { + return $this->field; + } + + public function getQueryParams() + { + $this->generateQueryParams(); + + return $this->query; + } + + public function generateQueryParams() + { + $this->query = [ + 'query' => [ + 'lucene' => [ + 'query' => "{$this->field}:*", + ], + ], + 'offset' => $this->offset, + 'limit' => $this->size, + ]; + } + + public function setType($type) + { + $this->setField("{$type}.{$this->field}"); + } }