Skip to content

Commit

Permalink
Merge pull request #456 from solariumphp/develop
Browse files Browse the repository at this point in the history
Creating new release
  • Loading branch information
basdenooijer authored Oct 28, 2016
2 parents 91fe408 + e800d95 commit 0acdb28
Show file tree
Hide file tree
Showing 21 changed files with 494 additions and 97 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## 3.7.0 - 2016-10-28

- added: support for nested documents in update query
- added: spatial component for select query
- added: support for keys and excludes in interval facet
- added: support for grouping using a function (group.func)
- bugfix: spellcheck collation parsing for Solr 5+
- improvement: lots of fixes in documentation markup
- added: included suggestion in composer file for a query builder library

## 3.6.0 - 2016-05-03

Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"zendframework/zendframework1": "~1.12",
"satooshi/php-coveralls": "~1.0"
},
"suggest": {
"minimalcode/search": "Query builder compatible with Solarium, allows simplified solr-query handling"
},
"extra": {
"branch-alias": {
"dev-develop": "3.3.x-dev"
Expand Down
8 changes: 5 additions & 3 deletions docs/customizing-solarium.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ By combining these options you can achieve almost any type of customization with

Solarium uses a separate library (included using Composer) for events. For more info on the Event Dispatcher take a look at [http://symfony.com/doc/2.0/components/event\_dispatcher/introduction.html the docs](http://symfony.com/doc/2.0/components/event_dispatcher/introduction.html_the_docs)

This example shows all available events and how to use the events to create a very basic debugger: ```php
This example shows all available events and how to use the events to create a very basic debugger:
```php
<?php
require(__DIR__.'/init.php');
use Solarium\Core\Event\Events;
Expand Down Expand Up @@ -230,7 +231,8 @@ htmlFooter();

```

The second example shows how to replace the built-in select querytype with a custom implementation: ```php
The second example shows how to replace the built-in select querytype with a custom implementation:
```php
<?php
require(__DIR__.'/init.php');
use Solarium\Client;
Expand Down Expand Up @@ -297,4 +299,4 @@ Extending Solarium classes
You can extend any class in Solarium, there is no use of 'private' or 'final'. However, Solarium does have several built-in class mappings for factory methods. Most important are the querytype mapping in Solarium\\Client and the component mapping in Solarium\\QueryType\\Select\\Query\\Query. In some cases you might need to alter this mappings for your classes to be used.
Other than that, there are no special issues to be expected. You can extend Solarium classes like any other PHP class.

If your use case can be solved using plugins that is probably the safest choice, as by extending classes you gain access to non-public methods in the API. These are subject to change in future releases, where the public API is not (except for major releases).
If your use case can be solved using plugins that is probably the safest choice, as by extending classes you gain access to non-public methods in the API. These are subject to change in future releases, where the public API is not (except for major releases).
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ See [<https://packagist.org>](https://packagist.org) for other packages.
```json
{
"require": {
"solarium/solarium": "2.4.0"
"solarium/solarium": "3.6.0"
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Options
Examples
--------

Grouping by field: ```php
Grouping by field:

```php
<?php

require(__DIR__.'/init.php');
Expand Down Expand Up @@ -82,7 +84,9 @@ htmlFooter();

```

Grouping by query: ```php
Grouping by query:

```php
<?php

require(__DIR__.'/init.php');
Expand Down
2 changes: 1 addition & 1 deletion library/Solarium/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Client extends CoreClient
*
* @var string
*/
const VERSION = '3.6.0';
const VERSION = '3.7.0';

/**
* Check for an exact version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function init()
break;
case 'exclude':
if (!is_array($value)) {
$value = array($value);
$value = explode(',', $value);
}
$this->setExcludes($value);
unset($this->options['exclude']);
Expand Down
96 changes: 96 additions & 0 deletions library/Solarium/QueryType/Select/Query/Component/Spatial.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

namespace Solarium\QueryType\Select\Query\Component;

use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\RequestBuilder\Component\Spatial as RequestBuilder;

/**
* Spatial component.
*
* @link https://cwiki.apache.org/confluence/display/solr/Spatial+Search
*/
class Spatial extends AbstractComponent
{
/**
* Get component type.
*
* @return string
*/
public function getType()
{
return SelectQuery::COMPONENT_SPATIAL;
}

/**
* Get a requestbuilder for this query.
*
* @return RequestBuilder
*/
public function getRequestBuilder()
{
return new RequestBuilder();
}

/**
* This component has no response parser...
*/
public function getResponseParser()
{
return;
}

/**
* @param string $sfield
*/
public function setField($sfield)
{
$this->setOption('sfield', $sfield);
}

/**
* @param int $distance
*/
public function setDistance($distance)
{
$this->setOption('d', $distance);
}

/**
* @param string $point
*/
public function setPoint($point)
{
$this->setOption('pt', $point);
}

/**
* Get sfield option.
*
* @return string|null
*/
public function getField()
{
return $this->getOption('sfield');
}

/**
* Get d option.
*
* @return int|null
*/
public function getDistance()
{
return $this->getOption('d');
}

/**
* Get pt option.
*
* @return int|null
*/
public function getPoint()
{
return $this->getOption('pt');
}
}
20 changes: 19 additions & 1 deletion library/Solarium/QueryType/Select/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ class Query extends BaseQuery
*/
const COMPONENT_DEBUG = 'debug';

/**
* Query component spatial.
*/
const COMPONENT_SPATIAL = 'spatial';

/**
* Default options.
*
Expand Down Expand Up @@ -166,6 +171,7 @@ class Query extends BaseQuery
self::COMPONENT_DISTRIBUTEDSEARCH => 'Solarium\QueryType\Select\Query\Component\DistributedSearch',
self::COMPONENT_STATS => 'Solarium\QueryType\Select\Query\Component\Stats\Stats',
self::COMPONENT_DEBUG => 'Solarium\QueryType\Select\Query\Component\Debug',
self::COMPONENT_SPATIAL => 'Solarium\QueryType\Select\Query\Component\Spatial',
);

/**
Expand Down Expand Up @@ -1057,6 +1063,18 @@ public function setTags($tags)
return $this->addTags($tags);
}

/**
* Get a Spatial component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\QueryType\Select\Query\Component\Spatial
*/
public function getSpatial()
{
return $this->getComponent(self::COMPONENT_SPATIAL, true);
}

/**
* Initialize options.
*
Expand Down Expand Up @@ -1090,7 +1108,7 @@ protected function init()
break;
case 'tag':
if (!is_array($value)) {
$value = array($value);
$value = explode(',', $value);
}
$this->addTags($value);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ public function addFacetInterval($request, $facet)
$request->addParam(
'facet.interval',
$this->renderLocalParams(
$field
// key & ex not supported for interval
//,array('key' => $facet->getKey(), 'ex' => $facet->getExcludes())
$field,
array('key' => $facet->getKey(), 'ex' => $facet->getExcludes())
)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Solarium\QueryType\Select\RequestBuilder\Component;

use Solarium\QueryType\Select\Query\Component\Spatial as SpatialComponent;
use Solarium\Core\Client\Request;

/**
* Add select component spatial to the request.
*/
class Spatial implements ComponentRequestBuilderInterface
{
/**
* Add request settings for Spatial.
*
* @param SpatialComponent $component
* @param Request $request
*
* @return Request
*/
public function buildComponent($component, $request)
{
$request->addParam('sfield', $component->getField());
$request->addParam('pt', $component->getPoint());
$request->addParam('d', $component->getDistance());

return $request;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public function parse($query, $grouping, $data)
// parse field groups
$valueResultClass = $grouping->getOption('resultvaluegroupclass');
$documentClass = $query->getOption('documentclass');
foreach ($grouping->getFields() as $field) {

// check grouping fields as well as the grouping function (either can be used in the query)
foreach (array_merge($grouping->getFields(), array($grouping->getFunction())) as $field) {
if (isset($data['grouped'][$field])) {
$result = $data['grouped'][$field];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@ protected function parseCollation($queryObject, $values)
if ($queryObject->getResponseWriter() == $queryObject::WT_JSON) {
if (is_array(current($values))) {
foreach ($values as $key => $value) {
$values[$key] = $this->convertToKeyValueArray($value);
if (array_key_exists('collationQuery', $value)) {
$values[$key] = $value;
} else {
$values[$key] = $this->convertToKeyValueArray($value);
}
}
} else {
$values = array($this->convertToKeyValueArray($values));
if (array_key_exists('collationQuery', $values)) {
$values = array($values);
} else {
$values = array($this->convertToKeyValueArray($values));
}
}
}

Expand Down
Loading

0 comments on commit 0acdb28

Please sign in to comment.