Commit 54c3b82d authored by Markus Kalkbrenner's avatar Markus Kalkbrenner Committed by GitHub

fixes #606 multiple dictionaries for suggesters (#607)

parent db7eace3
......@@ -8,9 +8,9 @@ See the example code below.
**Available options:**
| Name | Type | Default value | Description |
|-----------------|---------|---------------|----------------------------------------------------------------------------------------|
|-----------------|------------------|---------------|----------------------------------------------------------------------------------------|
| query | string | null | Query to spellcheck |
| dictionary | string | null | The name of the dictionary to use |
| dictionary | string or array | null | The name(s) of the dictionary or dictionaries to use |
| onlymorepopular | boolean | null | Only return suggestions that result in more hits for the query than the existing query |
| collate | boolean | null | |
||
......
......@@ -10,9 +10,9 @@ trait SuggesterTrait
/**
* Set dictionary option.
*
* The name of the dictionary to use
* The name of the dictionary or dictionaries to use
*
* @param string $dictionary
* @param string|array $dictionary
*
* @return self Provides fluent interface
*/
......
......@@ -37,4 +37,33 @@ class SuggesterTest extends TestCase
$request->getParams()
);
}
public function testBuildComponentMulipleDictionaries()
{
$builder = new RequestBuilder();
$request = new Request();
$component = new Component();
$component->setDictionary(['dictionary', 'alt_dictionary']);
$component->setQuery('ap ip');
$component->setCount(13);
$component->setContextFilterQuery('foo bar');
$component->setBuild('true');
$component->setReload('false');
$request = $builder->buildComponent($component, $request);
$this->assertEquals(
[
'suggest' => 'true',
'suggest.dictionary' => ['dictionary', 'alt_dictionary'],
'suggest.q' => 'ap ip',
'suggest.count' => 13,
'suggest.cfq' => 'foo bar',
'suggest.build' => 'true',
'suggest.reload' => 'false',
],
$request->getParams()
);
}
}
......@@ -119,6 +119,19 @@ class RequestBuilderTest extends TestCase
$this->assertSame('edismax', $request->getParam('defType'));
}
public function testWithSuggesterComponent()
{
$suggester = $this->query->getSuggester();
$suggester->setDictionary(['dict1', 'dict2']);
$request = $this->builder->build($this->query);
$this->assertSame(
'select?omitHeader=true&wt=json&json.nl=flat&q=*:*&start=0&rows=10&fl=*,score&suggest=true&suggest.dictionary=dict1&suggest.dictionary=dict2',
urldecode($request->getUri())
);
}
public function testWithTags()
{
$this->query->setTags(['t1', 't2']);
......
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