Commit 9af3e40e authored by Markus Kalkbrenner's avatar Markus Kalkbrenner

Merge branch 'master' of github.com:solariumphp/solarium

parents 3e60faad 0523e215
...@@ -5,8 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) ...@@ -5,8 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [4.0.0] ## [4.0.0]
### Changed ### Added
- Nothing compared to 4.0.0-rc.1 - Support "sow" parameter (Split On Whitespace) in select queries
## [4.0.0-rc.1] ## [4.0.0-rc.1]
### Added ### Added
......
...@@ -6,7 +6,7 @@ Options ...@@ -6,7 +6,7 @@ Options
The options below can be set as query option values, but also by using the set/get methods. See the API docs for all available methods. The options below can be set as query option values, but also by using the set/get methods. See the API docs for all available methods.
| Name | Type | Default value | Description | | Name | Type | Default value | Description |
|----------------------|------------------|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| |----------------------|------------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| handler | string | select | Name of the Solr request handler to use, without leading or trailing slashes | | handler | string | select | Name of the Solr request handler to use, without leading or trailing slashes |
| resultclass | string | Solarium\_Result\_Select | Classname for result. If you set a custom classname make sure the class is readily available (or through autoloading) | | resultclass | string | Solarium\_Result\_Select | Classname for result. If you set a custom classname make sure the class is readily available (or through autoloading) |
| documentclass | string | Solarium\_Document\_ReadWrite | Classname for documents in the resultset. If you set a custom classname make sure the class is readily available (or through autoloading) | | documentclass | string | Solarium\_Document\_ReadWrite | Classname for documents in the resultset. If you set a custom classname make sure the class is readily available (or through autoloading) |
...@@ -19,6 +19,7 @@ The options below can be set as query option values, but also by using the set/g ...@@ -19,6 +19,7 @@ The options below can be set as query option values, but also by using the set/g
| querydefaultfield | string | null | With a null value the default of your Solr config will be used. If you want to override this supply a field name as the value. | | querydefaultfield | string | null | With a null value the default of your Solr config will be used. If you want to override this supply a field name as the value. |
| responsewriter | string | json | You can set this to 'phps' for improved response parsing performance, at the cost of a (possible) security risk. Only use 'phps' for trusted Solr instances. | | responsewriter | string | json | You can set this to 'phps' for improved response parsing performance, at the cost of a (possible) security risk. Only use 'phps' for trusted Solr instances. |
| tag | array of strings | null | You can supply one or multiple tags for the main query string, to allow for exclusion of the main query in facets | | tag | array of strings | null | You can supply one or multiple tags for the main query string, to allow for exclusion of the main query in facets |
| splitonwhitespace | bool | null | Specifies whether the query parser splits the query text on whitespace before it's sent to be analyzed. Available for 'lucene' and 'edismax' query parsers since Solr 6.5. |
|| ||
Examples Examples
......
...@@ -763,6 +763,33 @@ class Query extends AbstractQuery implements ComponentAwareQueryInterface ...@@ -763,6 +763,33 @@ class Query extends AbstractQuery implements ComponentAwareQueryInterface
return $this->setOption('cursormark', null); return $this->setOption('cursormark', null);
} }
/**
* Set SplitOnWhitespace option.
*
* Specifies whether the query parser splits the query text on whitespace before it's sent to be analyzed.
*
* The default is to split on whitespace, equivalent to &sow=true.
* The sow parameter was introduced in Solr 6.5.
*
* @param bool $splitOnWhitespace
*
* @return self Provides fluent interface
*/
public function setSplitOnWhitespace($splitOnWhitespace)
{
return $this->setOption('splitonwhitespace', $splitOnWhitespace);
}
/**
* Get SplitOnWhitespace option.
*
* @return bool|null
*/
public function getSplitOnWhitespace()
{
return $this->getOption('splitonwhitespace');
}
/** /**
* Initialize options. * Initialize options.
* *
......
...@@ -37,6 +37,7 @@ class RequestBuilder extends BaseRequestBuilder ...@@ -37,6 +37,7 @@ class RequestBuilder extends BaseRequestBuilder
$request->addParam('q.op', $query->getQueryDefaultOperator()); $request->addParam('q.op', $query->getQueryDefaultOperator());
$request->addParam('df', $query->getQueryDefaultField()); $request->addParam('df', $query->getQueryDefaultField());
$request->addParam('cursorMark', $query->getCursormark()); $request->addParam('cursorMark', $query->getCursormark());
$request->addParam('sow', $query->getSplitOnWhitespace());
// add sort fields to request // add sort fields to request
$sort = []; $sort = [];
......
...@@ -689,6 +689,12 @@ abstract class AbstractQueryTest extends TestCase ...@@ -689,6 +689,12 @@ abstract class AbstractQueryTest extends TestCase
$this->assertSame(['t3', 't4'], $this->query->getTags()); $this->assertSame(['t3', 't4'], $this->query->getTags());
} }
public function testSetAndGetSplitOnWhitespace()
{
$this->query->setSplitOnWhitespace(false);
$this->assertFalse($this->query->getSplitOnWhitespace());
}
public function testGetSpatial() public function testGetSpatial()
{ {
$spatial = $this->query->getSpatial(); $spatial = $this->query->getSpatial();
......
...@@ -127,6 +127,14 @@ class RequestBuilderTest extends TestCase ...@@ -127,6 +127,14 @@ class RequestBuilderTest extends TestCase
$this->assertSame('{!tag=t1,t2}cat:1', $request->getParam('q')); $this->assertSame('{!tag=t1,t2}cat:1', $request->getParam('q'));
} }
public function testWithSplitOnWhitespace()
{
$this->query->setSplitOnWhitespace(false);
$request = $this->builder->build($this->query);
$this->assertSame('false', $request->getParam('sow'));
}
} }
class TestDummyComponent extends AbstractComponent class TestDummyComponent extends AbstractComponent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment