Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
39256a07
Commit
39256a07
authored
Jan 06, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added hl.q and hl.phraseLimit support to highlighting component
parent
b81e2892
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
0 deletions
+76
-0
library/Solarium/Client/RequestBuilder/Select/Component/Highlighting.php
...m/Client/RequestBuilder/Select/Component/Highlighting.php
+2
-0
library/Solarium/Query/Select/Component/Highlighting.php
library/Solarium/Query/Select/Component/Highlighting.php
+44
-0
tests/Solarium/Client/RequestBuilder/Select/Component/HighlightingTest.php
...ient/RequestBuilder/Select/Component/HighlightingTest.php
+4
-0
tests/Solarium/Query/Select/Component/HighlightingTest.php
tests/Solarium/Query/Select/Component/HighlightingTest.php
+26
-0
No files found.
library/Solarium/Client/RequestBuilder/Select/Component/Highlighting.php
View file @
39256a07
...
@@ -78,6 +78,8 @@ class Solarium_Client_RequestBuilder_Select_Component_Highlighting
...
@@ -78,6 +78,8 @@ class Solarium_Client_RequestBuilder_Select_Component_Highlighting
$request
->
addParam
(
'hl.regex.slop'
,
$component
->
getRegexSlop
());
$request
->
addParam
(
'hl.regex.slop'
,
$component
->
getRegexSlop
());
$request
->
addParam
(
'hl.regex.pattern'
,
$component
->
getRegexPattern
());
$request
->
addParam
(
'hl.regex.pattern'
,
$component
->
getRegexPattern
());
$request
->
addParam
(
'hl.regex.maxAnalyzedChars'
,
$component
->
getRegexMaxAnalyzedChars
());
$request
->
addParam
(
'hl.regex.maxAnalyzedChars'
,
$component
->
getRegexMaxAnalyzedChars
());
$request
->
addParam
(
'hl.q'
,
$component
->
getQuery
());
$request
->
addParam
(
'hl.phraseLimit'
,
$component
->
getPhraseLimit
());
// set per-field highlighting params
// set per-field highlighting params
foreach
(
$component
->
getFields
()
as
$field
)
{
foreach
(
$component
->
getFields
()
as
$field
)
{
...
...
library/Solarium/Query/Select/Component/Highlighting.php
View file @
39256a07
...
@@ -628,4 +628,48 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
...
@@ -628,4 +628,48 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
return
$this
->
getOption
(
'regexmaxanalyzedchars'
);
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
tests/Solarium/Client/RequestBuilder/Select/Component/HighlightingTest.php
View file @
39256a07
...
@@ -70,6 +70,8 @@ class Solarium_Client_RequestBuilder_Select_Component_HighlightingTest extends P
...
@@ -70,6 +70,8 @@ class Solarium_Client_RequestBuilder_Select_Component_HighlightingTest extends P
$component
->
setRegexSlop
(
1.3
);
$component
->
setRegexSlop
(
1.3
);
$component
->
setRegexPattern
(
'mypattern'
);
$component
->
setRegexPattern
(
'mypattern'
);
$component
->
setMaxAnalyzedChars
(
100
);
$component
->
setMaxAnalyzedChars
(
100
);
$component
->
setQuery
(
'text:myvalue'
);
$component
->
setPhraseLimit
(
40
);
$request
=
$builder
->
build
(
$component
,
$request
);
$request
=
$builder
->
build
(
$component
,
$request
);
...
@@ -95,6 +97,8 @@ class Solarium_Client_RequestBuilder_Select_Component_HighlightingTest extends P
...
@@ -95,6 +97,8 @@ class Solarium_Client_RequestBuilder_Select_Component_HighlightingTest extends P
'hl.highlightMultiTerm'
=>
'true'
,
'hl.highlightMultiTerm'
=>
'true'
,
'hl.regex.slop'
=>
1.3
,
'hl.regex.slop'
=>
1.3
,
'hl.regex.pattern'
=>
'mypattern'
,
'hl.regex.pattern'
=>
'mypattern'
,
'hl.q'
=>
'text:myvalue'
,
'hl.phraseLimit'
=>
40
,
'f.fieldB.hl.snippets'
=>
3
,
'f.fieldB.hl.snippets'
=>
3
,
'f.fieldB.hl.fragsize'
=>
25
,
'f.fieldB.hl.fragsize'
=>
25
,
'f.fieldB.hl.mergeContiguous'
=>
'true'
,
'f.fieldB.hl.mergeContiguous'
=>
'true'
,
...
...
tests/Solarium/Query/Select/Component/HighlightingTest.php
View file @
39256a07
...
@@ -71,6 +71,8 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
...
@@ -71,6 +71,8 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
'regexslop'
=>
.
8
,
'regexslop'
=>
.
8
,
'regexpattern'
=>
'myPattern'
,
'regexpattern'
=>
'myPattern'
,
'regexmaxanalyzedchars'
=>
500
,
'regexmaxanalyzedchars'
=>
500
,
'query'
=>
'text:myvalue'
,
'phraselimit'
=>
35
,
);
);
...
@@ -98,6 +100,8 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
...
@@ -98,6 +100,8 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
$this
->
assertEquals
(
$options
[
'regexslop'
],
$this
->
_hlt
->
getRegexSlop
());
$this
->
assertEquals
(
$options
[
'regexslop'
],
$this
->
_hlt
->
getRegexSlop
());
$this
->
assertEquals
(
$options
[
'regexpattern'
],
$this
->
_hlt
->
getRegexPattern
());
$this
->
assertEquals
(
$options
[
'regexpattern'
],
$this
->
_hlt
->
getRegexPattern
());
$this
->
assertEquals
(
$options
[
'regexmaxanalyzedchars'
],
$this
->
_hlt
->
getRegexMaxAnalyzedChars
());
$this
->
assertEquals
(
$options
[
'regexmaxanalyzedchars'
],
$this
->
_hlt
->
getRegexMaxAnalyzedChars
());
$this
->
assertEquals
(
$options
[
'query'
],
$this
->
_hlt
->
getQuery
());
$this
->
assertEquals
(
$options
[
'phraselimit'
],
$this
->
_hlt
->
getPhraseLimit
());
}
}
public
function
testGetType
()
public
function
testGetType
()
...
@@ -447,4 +451,26 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
...
@@ -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
()
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment