Skip to content

Commit

Permalink
Merge pull request #33 from byng-systems/development_prefix_query
Browse files Browse the repository at this point in the history
Development prefix query
  • Loading branch information
asim-inviqa authored Nov 4, 2016
2 parents 8a72c7d + c5a25b8 commit 0c8e14a
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Gateway/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,24 @@ protected function processQuery(QueryInterface $query)
$query->getField() => $query->getTerms()
];
break;

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

case "regexp":
$result["regexp"] = [
$query->getField() => $query->getQuery()
];
break;

case "wildcard":
$result["wildcard"] = [
$query->getField() => $query->getQuery()
];
break;

case "constant_score":
$result["constant_score"] = $this->processQuery($query->getFilter());
Expand Down
76 changes: 76 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Query/Prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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;

/**
* Prefix Query
*
* Allows to do prefix queries
*
* @author Asim Liaquat <[email protected]>
*/
final class Prefix implements QueryInterface
{

/**
* @var string
*/
private $field;

/**
* @var string
*/
private $query;

/**
* Prefix constructor.
*
* @param string $field
* @param string $query
*/
public function __construct($field, $query)
{
$this->field = $field;
$this->query = $query;
}

/**
* Get field
*
* @return string
*/
public function getField()
{
return $this->field;
}

/**
* Get query
*
* @return string
*/
public function getQuery()
{
return $this->query;
}

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

}
18 changes: 18 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,24 @@ protected function processQuery(QueryInterface $query)
];
break;

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

case "regexp":
$result["regexp"] = [
$query->getField() => $query->getQuery()
];
break;

case "wildcard":
$result["wildcard"] = [
$query->getField() => $query->getQuery()
];
break;

case "constant_score":
$result["constant_score"] = $this->processQuery($query->getFilter());
break;
Expand Down
76 changes: 76 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Query/Regexp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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;

/**
* Regexp Query
*
* Allows to do regexp queries
*
* @author Asim Liaquat <[email protected]>
*/
final class Regexp implements QueryInterface
{

/**
* @var string
*/
private $field;

/**
* @var string
*/
private $query;

/**
* Regexp constructor.
*
* @param string $field
* @param string $query
*/
public function __construct($field, $query)
{
$this->field = $field;
$this->query = $query;
}

/**
* Get field
*
* @return string
*/
public function getField()
{
return $this->field;
}

/**
* Get query
*
* @return string
*/
public function getQuery()
{
return $this->query;
}

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

}
76 changes: 76 additions & 0 deletions lib/Byng/Pimcore/Elasticsearch/Query/Wildcard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?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;

/**
* Wildcard Query
*
* Allows to do wildcard queries
*
* @author Asim Liaquat <[email protected]>
*/
final class Wildcard implements QueryInterface
{

/**
* @var string
*/
private $field;

/**
* @var string
*/
private $query;

/**
* Wildcard constructor.
*
* @param string $field
* @param string $query
*/
public function __construct($field, $query)
{
$this->field = $field;
$this->query = $query;
}

/**
* Get field
*
* @return string
*/
public function getField()
{
return $this->field;
}

/**
* Get query
*
* @return string
*/
public function getQuery()
{
return $this->query;
}

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

}

0 comments on commit 0c8e14a

Please sign in to comment.