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
96917f2e
Commit
96917f2e
authored
Jan 04, 2013
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for new highlighting parameters
parent
ea5bb5c3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
206 additions
and
0 deletions
+206
-0
library/Solarium/QueryType/Select/Query/Component/Highlighting/Highlighting.php
...Type/Select/Query/Component/Highlighting/Highlighting.php
+126
-0
library/Solarium/QueryType/Select/RequestBuilder/Component/Highlighting.php
...ueryType/Select/RequestBuilder/Component/Highlighting.php
+5
-0
tests/Solarium/Tests/QueryType/Select/Query/Component/Highlighting/HighlightingTest.php
.../Select/Query/Component/Highlighting/HighlightingTest.php
+65
-0
tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/HighlightingTest.php
...Type/Select/RequestBuilder/Component/HighlightingTest.php
+10
-0
No files found.
library/Solarium/QueryType/Select/Query/Component/Highlighting/Highlighting.php
View file @
96917f2e
...
@@ -60,6 +60,26 @@ class Highlighting extends Component
...
@@ -60,6 +60,26 @@ class Highlighting extends Component
*/
*/
const
FRAGMENTER_REGEX
=
'regex'
;
const
FRAGMENTER_REGEX
=
'regex'
;
/**
* Value for BoundaryScanner type
*/
const
BOUNDARYSCANNER_TYPE_CHARACTER
=
'CHARACTER'
;
/**
* Value for BoundaryScanner type
*/
const
BOUNDARYSCANNER_TYPE_WORD
=
'WORD'
;
/**
* Value for BoundaryScanner type
*/
const
BOUNDARYSCANNER_TYPE_SENTENCE
=
'SENTENCE'
;
/**
* Value for BoundaryScanner type
*/
const
BOUNDARYSCANNER_TYPE_LINE
=
'LINE'
;
/**
/**
* Array of fields for highlighting
* Array of fields for highlighting
*
*
...
@@ -774,4 +794,110 @@ class Highlighting extends Component
...
@@ -774,4 +794,110 @@ class Highlighting extends Component
return
$this
->
getOption
(
'multivaluedseparatorchar'
);
return
$this
->
getOption
(
'multivaluedseparatorchar'
);
}
}
/**
* Set boundaryscannermaxscan option
*
* @param int $maximum
* @return self Provides fluent interface
*/
public
function
setBoundaryScannerMaxScan
(
$maximum
)
{
return
$this
->
setOption
(
'boundaryscannermaxscan'
,
$maximum
);
}
/**
* Get boundaryscannermaxscan option
*
* @return int|null
*/
public
function
getBoundaryScannerMaxScan
()
{
return
$this
->
getOption
(
'boundaryscannermaxscan'
);
}
/**
* Set boundaryscannerchars option
*
* @param string $chars
* @return self Provides fluent interface
*/
public
function
setBoundaryScannerChars
(
$chars
)
{
return
$this
->
setOption
(
'boundaryscannerchars'
,
$chars
);
}
/**
* Get boundaryscannerchars option
*
* @return string|null
*/
public
function
getBoundaryScannerChars
()
{
return
$this
->
getOption
(
'boundaryscannerchars'
);
}
/**
* Set boundaryscannertype option
*
* @param string $type
* @return self Provides fluent interface
*/
public
function
setBoundaryScannerType
(
$type
)
{
return
$this
->
setOption
(
'boundaryscannertype'
,
$type
);
}
/**
* Get boundaryscannertype option
*
* @return string|null
*/
public
function
getBoundaryScannerType
()
{
return
$this
->
getOption
(
'boundaryscannertype'
);
}
/**
* Set boundaryscannerlanguage option
*
* @param string $language
* @return self Provides fluent interface
*/
public
function
setBoundaryScannerLanguage
(
$language
)
{
return
$this
->
setOption
(
'boundaryscannerlanguage'
,
$language
);
}
/**
* Get boundaryscannerlanguage option
*
* @return string|null
*/
public
function
getBoundaryScannerLanguage
()
{
return
$this
->
getOption
(
'boundaryscannerlanguage'
);
}
/**
* Set boundaryscannercountry option
*
* @param string $country
* @return self Provides fluent interface
*/
public
function
setBoundaryScannerCountry
(
$country
)
{
return
$this
->
setOption
(
'boundaryscannercountry'
,
$country
);
}
/**
* Get boundaryscannercountry option
*
* @return string|null
*/
public
function
getBoundaryScannerCountry
()
{
return
$this
->
getOption
(
'boundaryscannercountry'
);
}
}
}
library/Solarium/QueryType/Select/RequestBuilder/Component/Highlighting.php
View file @
96917f2e
...
@@ -85,6 +85,11 @@ class Highlighting implements ComponentRequestBuilderInterface
...
@@ -85,6 +85,11 @@ class Highlighting implements ComponentRequestBuilderInterface
$request
->
addParam
(
'hl.q'
,
$component
->
getQuery
());
$request
->
addParam
(
'hl.q'
,
$component
->
getQuery
());
$request
->
addParam
(
'hl.phraseLimit'
,
$component
->
getPhraseLimit
());
$request
->
addParam
(
'hl.phraseLimit'
,
$component
->
getPhraseLimit
());
$request
->
addParam
(
'hl.multiValuedSeparatorChar'
,
$component
->
getMultiValuedSeparatorChar
());
$request
->
addParam
(
'hl.multiValuedSeparatorChar'
,
$component
->
getMultiValuedSeparatorChar
());
$request
->
addParam
(
'hl.bs.maxScan'
,
$component
->
getBoundaryScannerMaxScan
());
$request
->
addParam
(
'hl.bs.chars'
,
$component
->
getBoundaryScannerChars
());
$request
->
addParam
(
'hl.bs.type'
,
$component
->
getBoundaryScannerType
());
$request
->
addParam
(
'hl.bs.language'
,
$component
->
getBoundaryScannerLanguage
());
$request
->
addParam
(
'hl.bs.country'
,
$component
->
getBoundaryScannerCountry
());
// set per-field highlighting params
// set per-field highlighting params
foreach
(
$component
->
getFields
()
as
$field
)
{
foreach
(
$component
->
getFields
()
as
$field
)
{
...
...
tests/Solarium/Tests/QueryType/Select/Query/Component/Highlighting/HighlightingTest.php
View file @
96917f2e
...
@@ -81,6 +81,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
...
@@ -81,6 +81,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
'query'
=>
'text:myvalue'
,
'query'
=>
'text:myvalue'
,
'phraselimit'
=>
35
,
'phraselimit'
=>
35
,
'multivaluedseparatorchar'
=>
'|'
,
'multivaluedseparatorchar'
=>
'|'
,
'boundaryscannermaxscan'
=>
12
,
'boundaryscannerchars'
=>
"
\t\n
"
,
'boundaryscannertype'
=>
'LINE'
,
'boundaryscannerlanguage'
=>
'nl'
,
'boundaryscannercountry'
=>
'NL'
,
);
);
$this
->
hlt
->
setOptions
(
$options
);
$this
->
hlt
->
setOptions
(
$options
);
...
@@ -112,6 +117,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
...
@@ -112,6 +117,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$options
[
'query'
],
$this
->
hlt
->
getQuery
());
$this
->
assertEquals
(
$options
[
'query'
],
$this
->
hlt
->
getQuery
());
$this
->
assertEquals
(
$options
[
'phraselimit'
],
$this
->
hlt
->
getPhraseLimit
());
$this
->
assertEquals
(
$options
[
'phraselimit'
],
$this
->
hlt
->
getPhraseLimit
());
$this
->
assertEquals
(
$options
[
'multivaluedseparatorchar'
],
$this
->
hlt
->
getMultiValuedSeparatorChar
());
$this
->
assertEquals
(
$options
[
'multivaluedseparatorchar'
],
$this
->
hlt
->
getMultiValuedSeparatorChar
());
$this
->
assertEquals
(
$options
[
'boundaryscannermaxscan'
],
$this
->
hlt
->
getBoundaryScannerMaxScan
());
$this
->
assertEquals
(
$options
[
'boundaryscannerchars'
],
$this
->
hlt
->
getBoundaryScannerChars
());
$this
->
assertEquals
(
$options
[
'boundaryscannertype'
],
$this
->
hlt
->
getBoundaryScannerType
());
$this
->
assertEquals
(
$options
[
'boundaryscannerlanguage'
],
$this
->
hlt
->
getBoundaryScannerLanguage
());
$this
->
assertEquals
(
$options
[
'boundaryscannercountry'
],
$this
->
hlt
->
getBoundaryScannerCountry
());
}
}
public
function
testGetType
()
public
function
testGetType
()
...
@@ -525,4 +535,59 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
...
@@ -525,4 +535,59 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
);
);
}
}
public
function
testSetAndGetBoundaryScannerChars
()
{
$value
=
"
\n
"
;
$this
->
hlt
->
setBoundaryScannerChars
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
hlt
->
getBoundaryScannerChars
()
);
}
public
function
testSetAndGetBoundaryScannerMaxScan
()
{
$value
=
15
;
$this
->
hlt
->
setBoundaryScannerMaxScan
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
hlt
->
getBoundaryScannerMaxScan
()
);
}
public
function
testSetAndGetBoundaryScannerType
()
{
$value
=
'SENTENCE'
;
$this
->
hlt
->
setBoundaryScannerType
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
hlt
->
getBoundaryScannerType
()
);
}
public
function
testSetAndGetBoundaryScannerCountry
()
{
$value
=
'DE'
;
$this
->
hlt
->
setBoundaryScannerCountry
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
hlt
->
getBoundaryScannerCountry
()
);
}
public
function
testSetAndGetBoundaryScannerLanguage
()
{
$value
=
'fr'
;
$this
->
hlt
->
setBoundaryScannerLanguage
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
hlt
->
getBoundaryScannerLanguage
()
);
}
}
}
tests/Solarium/Tests/QueryType/Select/RequestBuilder/Component/HighlightingTest.php
View file @
96917f2e
...
@@ -80,6 +80,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
...
@@ -80,6 +80,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
$component
->
setTagPrefix
(
'<i>'
);
$component
->
setTagPrefix
(
'<i>'
);
$component
->
setTagPostfix
(
'</i>'
);
$component
->
setTagPostfix
(
'</i>'
);
$component
->
setMultiValuedSeparatorChar
(
'|'
);
$component
->
setMultiValuedSeparatorChar
(
'|'
);
$component
->
setBoundaryScannerChars
(
'.,'
);
$component
->
setBoundaryScannerMaxScan
(
16
);
$component
->
setBoundaryScannerType
(
$component
::
BOUNDARYSCANNER_TYPE_WORD
);
$component
->
setBoundaryScannerCountry
(
'be'
);
$component
->
setBoundaryScannerLanguage
(
'en'
);
$request
=
$builder
->
buildComponent
(
$component
,
$request
);
$request
=
$builder
->
buildComponent
(
$component
,
$request
);
...
@@ -119,6 +124,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
...
@@ -119,6 +124,11 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
'f.fieldB.hl.simple.post'
=>
'</b>'
,
'f.fieldB.hl.simple.post'
=>
'</b>'
,
'f.fieldB.hl.fragmenter'
=>
'myFragmenter'
,
'f.fieldB.hl.fragmenter'
=>
'myFragmenter'
,
'f.fieldB.hl.useFastVectorHighlighter'
=>
'true'
,
'f.fieldB.hl.useFastVectorHighlighter'
=>
'true'
,
'hl.bs.maxScan'
=>
16
,
'hl.bs.chars'
=>
'.,'
,
'hl.bs.type'
=>
'WORD'
,
'hl.bs.country'
=>
'be'
,
'hl.bs.language'
=>
'en'
,
),
),
$request
->
getParams
()
$request
->
getParams
()
);
);
...
...
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