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
d88ed3fb
Unverified
Commit
d88ed3fb
authored
Dec 20, 2017
by
Markus Kalkbrenner
Committed by
GitHub
Dec 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4.x suggester (#535)
Cleaned up suggester query and added missing parameters
parent
5702044e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
26 deletions
+79
-26
library/Solarium/QueryType/Suggester/Query.php
library/Solarium/QueryType/Suggester/Query.php
+39
-15
library/Solarium/QueryType/Suggester/RequestBuilder.php
library/Solarium/QueryType/Suggester/RequestBuilder.php
+4
-1
tests/Solarium/Tests/QueryType/Suggester/QueryTest.php
tests/Solarium/Tests/QueryType/Suggester/QueryTest.php
+29
-8
tests/Solarium/Tests/QueryType/Suggester/RequestBuilderTest.php
...Solarium/Tests/QueryType/Suggester/RequestBuilderTest.php
+7
-2
No files found.
library/Solarium/QueryType/Suggester/Query.php
View file @
d88ed3fb
...
@@ -60,6 +60,8 @@ class Query extends BaseQuery
...
@@ -60,6 +60,8 @@ class Query extends BaseQuery
'resultclass'
=>
'Solarium\QueryType\Suggester\Result\Result'
,
'resultclass'
=>
'Solarium\QueryType\Suggester\Result\Result'
,
'termclass'
=>
'Solarium\QueryType\Suggester\Result\Term'
,
'termclass'
=>
'Solarium\QueryType\Suggester\Result\Term'
,
'omitheader'
=>
true
,
'omitheader'
=>
true
,
'build'
=>
false
,
'reload'
=>
false
,
);
);
/**
/**
...
@@ -165,48 +167,70 @@ class Query extends BaseQuery
...
@@ -165,48 +167,70 @@ class Query extends BaseQuery
}
}
/**
/**
* Set
onlyMorePopular
option.
* Set
cfq
option.
*
*
*
Only return suggestions that result in more hits for the query than the existing query
*
A Context Filter Query used to filter suggestions based on the context field, if supported by the suggester.
*
*
* @param
boolean $onlyMorePopular
* @param
string $cfq
*
*
* @return self Provides fluent interface
* @return self Provides fluent interface
*/
*/
public
function
set
OnlyMorePopular
(
$onlyMorePopular
)
public
function
set
ContextFilterQuery
(
$cfq
)
{
{
return
$this
->
setOption
(
'
onlymorepopular'
,
$onlyMorePopular
);
return
$this
->
setOption
(
'
cfq'
,
$cfq
);
}
}
/**
/**
* Get onlyMorePopular option.
* Get cfq option.
*
* @return string|null
*/
public
function
getContextFilterQuery
()
{
return
$this
->
getOption
(
'cfq'
);
}
/**
* Set build option.
*
* @param boolean $build
*
* @return self Provides fluent interface
*/
public
function
setBuild
(
$build
)
{
return
$this
->
setOption
(
'build'
,
$build
);
}
/**
* Get build option.
*
*
* @return boolean|null
* @return boolean|null
*/
*/
public
function
get
OnlyMorePopular
()
public
function
get
Build
()
{
{
return
$this
->
getOption
(
'
onlymorepopular
'
);
return
$this
->
getOption
(
'
build
'
);
}
}
/**
/**
* Set
collate
option.
* Set
reload
option.
*
*
* @param boolean $
collate
* @param boolean $
build
*
*
* @return self Provides fluent interface
* @return self Provides fluent interface
*/
*/
public
function
set
Collate
(
$collate
)
public
function
set
Reload
(
$reload
)
{
{
return
$this
->
setOption
(
'collate'
,
$collate
);
return
$this
->
setOption
(
'reload'
,
$reload
);
}
}
/**
/**
* Get
collate
option.
* Get
reload
option.
*
*
* @return boolean|null
* @return boolean|null
*/
*/
public
function
get
Collate
()
public
function
get
Reload
()
{
{
return
$this
->
getOption
(
'collate
'
);
return
$this
->
getOption
(
'reload
'
);
}
}
}
}
library/Solarium/QueryType/Suggester/RequestBuilder.php
View file @
d88ed3fb
...
@@ -60,9 +60,12 @@ class RequestBuilder extends BaseRequestBuilder
...
@@ -60,9 +60,12 @@ class RequestBuilder extends BaseRequestBuilder
{
{
$request
=
parent
::
build
(
$query
);
$request
=
parent
::
build
(
$query
);
$request
->
addParam
(
'suggest'
,
'true'
);
$request
->
addParam
(
'suggest'
,
'true'
);
$request
->
addParam
(
'suggest.q'
,
$query
->
getQuery
());
$request
->
addParam
(
'suggest.dictionary'
,
$query
->
getDictionary
());
$request
->
addParam
(
'suggest.dictionary'
,
$query
->
getDictionary
());
$request
->
addParam
(
'suggest.q'
,
$query
->
getQuery
());
$request
->
addParam
(
'suggest.count'
,
$query
->
getCount
());
$request
->
addParam
(
'suggest.count'
,
$query
->
getCount
());
$request
->
addParam
(
'suggest.cfq'
,
$query
->
getContextFilterQuery
());
$request
->
addParam
(
'suggest.build'
,
$query
->
getBuild
());
$request
->
addParam
(
'suggest.reload'
,
$query
->
getReload
());
return
$request
;
return
$request
;
}
}
...
...
tests/Solarium/Tests/QueryType/Suggester/QueryTest.php
View file @
d88ed3fb
...
@@ -94,25 +94,46 @@ class QueryTest extends \PHPUnit_Framework_TestCase
...
@@ -94,25 +94,46 @@ class QueryTest extends \PHPUnit_Framework_TestCase
);
);
}
}
public
function
testSetAndGet
OnlyMorePopular
()
public
function
testSetAndGet
ContextFilterQuery
()
{
{
$value
=
false
;
$value
=
'context filter query'
;
$this
->
query
->
set
OnlyMorePopular
(
$value
);
$this
->
query
->
set
ContextFilterQuery
(
$value
);
$this
->
assertEquals
(
$this
->
assertEquals
(
$value
,
$value
,
$this
->
query
->
get
OnlyMorePopular
()
$this
->
query
->
get
ContextFilterQuery
()
);
);
}
}
public
function
testSetAnd
GetCollate
()
public
function
testSetAnd
Build
()
{
{
$value
=
false
;
$this
->
assertEquals
(
$this
->
query
->
setCollate
(
$value
);
false
,
$this
->
query
->
getBuild
()
);
$value
=
true
;
$this
->
query
->
setBuild
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
query
->
getBuild
()
);
}
public
function
testSetAndReload
()
{
$this
->
assertEquals
(
false
,
$this
->
query
->
getReload
()
);
$value
=
true
;
$this
->
query
->
setReload
(
$value
);
$this
->
assertEquals
(
$this
->
assertEquals
(
$value
,
$value
,
$this
->
query
->
get
Collate
()
$this
->
query
->
get
Reload
()
);
);
}
}
}
}
tests/Solarium/Tests/QueryType/Suggester/RequestBuilderTest.php
View file @
d88ed3fb
...
@@ -55,18 +55,23 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
...
@@ -55,18 +55,23 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public
function
testBuildParams
()
public
function
testBuildParams
()
{
{
$this
->
query
->
setCount
(
13
);
$this
->
query
->
setDictionary
(
'suggest'
);
$this
->
query
->
setDictionary
(
'suggest'
);
$this
->
query
->
setQuery
(
'ap ip'
);
$this
->
query
->
setQuery
(
'ap ip'
);
$this
->
query
->
setCount
(
13
);
$this
->
query
->
setContextFilterQuery
(
'foo bar'
);
$this
->
query
->
setBuild
(
'true'
);
$request
=
$this
->
builder
->
build
(
$this
->
query
);
$request
=
$this
->
builder
->
build
(
$this
->
query
);
$this
->
assertEquals
(
$this
->
assertEquals
(
array
(
array
(
'suggest'
=>
'true'
,
'suggest'
=>
'true'
,
'suggest.q'
=>
'ap ip'
,
'suggest.dictionary'
=>
'suggest'
,
'suggest.dictionary'
=>
'suggest'
,
'suggest.q'
=>
'ap ip'
,
'suggest.count'
=>
13
,
'suggest.count'
=>
13
,
'suggest.cfq'
=>
'foo bar'
,
'suggest.build'
=>
'true'
,
'suggest.reload'
=>
'false'
,
'wt'
=>
'json'
,
'wt'
=>
'json'
,
'json.nl'
=>
'flat'
,
'json.nl'
=>
'flat'
,
'omitHeader'
=>
'true'
,
'omitHeader'
=>
'true'
,
...
...
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