Commit 39256a07 authored by Bas de Nooijer's avatar Bas de Nooijer

Added hl.q and hl.phraseLimit support to highlighting component

parent b81e2892
......@@ -78,6 +78,8 @@ class Solarium_Client_RequestBuilder_Select_Component_Highlighting
$request->addParam('hl.regex.slop', $component->getRegexSlop());
$request->addParam('hl.regex.pattern', $component->getRegexPattern());
$request->addParam('hl.regex.maxAnalyzedChars', $component->getRegexMaxAnalyzedChars());
$request->addParam('hl.q', $component->getQuery());
$request->addParam('hl.phraseLimit', $component->getPhraseLimit());
// set per-field highlighting params
foreach ($component->getFields() as $field) {
......
......@@ -628,4 +628,48 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
return $this->getOption('regexmaxanalyzedchars');
}
/**
* Set highlight query option
*
* Overrides the q parameter for highlighting
*
* @param string $query
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setQuery($query)
{
return $this->_setOption('query', $query);
}
/**
* Get query option
*
* @return string|null
*/
public function getQuery()
{
return $this->getOption('query');
}
/**
* Set phraselimit option
*
* @param int $maximum
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setPhraseLimit($maximum)
{
return $this->_setOption('phraselimit', $maximum);
}
/**
* Get phraselimit option
*
* @return int|null
*/
public function getPhraseLimit()
{
return $this->getOption('phraselimit');
}
}
\ No newline at end of file
......@@ -70,6 +70,8 @@ class Solarium_Client_RequestBuilder_Select_Component_HighlightingTest extends P
$component->setRegexSlop(1.3);
$component->setRegexPattern('mypattern');
$component->setMaxAnalyzedChars(100);
$component->setQuery('text:myvalue');
$component->setPhraseLimit(40);
$request = $builder->build($component, $request);
......@@ -95,6 +97,8 @@ class Solarium_Client_RequestBuilder_Select_Component_HighlightingTest extends P
'hl.highlightMultiTerm' => 'true',
'hl.regex.slop' => 1.3,
'hl.regex.pattern' => 'mypattern',
'hl.q' => 'text:myvalue',
'hl.phraseLimit' => 40,
'f.fieldB.hl.snippets' => 3,
'f.fieldB.hl.fragsize' => 25,
'f.fieldB.hl.mergeContiguous' => 'true',
......
......@@ -71,6 +71,8 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
'regexslop' => .8,
'regexpattern' => 'myPattern',
'regexmaxanalyzedchars' => 500,
'query' => 'text:myvalue',
'phraselimit' => 35,
);
......@@ -98,6 +100,8 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
$this->assertEquals($options['regexslop'], $this->_hlt->getRegexSlop());
$this->assertEquals($options['regexpattern'], $this->_hlt->getRegexPattern());
$this->assertEquals($options['regexmaxanalyzedchars'], $this->_hlt->getRegexMaxAnalyzedChars());
$this->assertEquals($options['query'], $this->_hlt->getQuery());
$this->assertEquals($options['phraselimit'], $this->_hlt->getPhraseLimit());
}
public function testGetType()
......@@ -447,4 +451,26 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
);
}
public function testSetAndGetQuery()
{
$value = 'text:myvalue';
$this->_hlt->setQuery($value);
$this->assertEquals(
$value,
$this->_hlt->getQuery()
);
}
public function testSetAndGetPhraseLimit()
{
$value = 20;
$this->_hlt->setPhraseLimit($value);
$this->assertEquals(
$value,
$this->_hlt->getPhraseLimit()
);
}
}
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