Skip to content

Commit

Permalink
Added ids query
Browse files Browse the repository at this point in the history
  • Loading branch information
asimlqt committed Jul 21, 2017
1 parent 32d2949 commit 8768fec
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ protected function processQuery(QueryInterface $query)
];
break;

case "ids":
$result["ids"] = [
"type" => $query->getIndexType(),
"values" => $query->getValues()
];
break;

case "prefix":
$result["prefix"] = [
$query->getField() => $query->getQuery()
Expand Down
75 changes: 75 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Query/IdsQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/**
* This file is part of the "byng/pimcore-elasticsearch-plugin" project.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the LICENSE is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Byng\Pimcore\Elasticsearch\Query;

/**
* Ids Query
*
* Allows you to search only within documents that have the specified ids
*
* @author Asim Liaquat <[email protected]>
*/
final class IdsQuery implements QueryInterface
{
/**
* @var string
*/
private $indexType;

/**
* @var array
*/
private $values;

/**
* IdsQuery constructor.
*
* @param string $indexType
* @param array $values
*/
public function __construct($indexType, array $values)
{
$this->indexType = $indexType;
$this->values = $values;
}

/**
* Get type
*
* @return string
*/
public function getIndexType()
{
return $this->indexType;
}

/**
* Get values
*
* @return array
*/
public function getValues()
{
return $this->values;
}

/**
* {@inheritdoc}
*/
public function getType()
{
return "ids";
}

}
7 changes: 7 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ protected function processQuery(QueryInterface $query)
];
break;

case "ids":
$result["ids"] = [
"type" => $query->getIndexType(),
"values" => $query->getValues()
];
break;

case "prefix":
$result["prefix"] = [
$query->getField() => $query->getQuery()
Expand Down

0 comments on commit 8768fec

Please sign in to comment.