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
2e3a1b13
Commit
2e3a1b13
authored
Jan 29, 2014
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added matchoffset setting to MLT querytype (closes #233)
parent
5341fdb6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
2 deletions
+41
-2
library/Solarium/QueryType/MoreLikeThis/Query.php
library/Solarium/QueryType/MoreLikeThis/Query.php
+25
-0
library/Solarium/QueryType/MoreLikeThis/RequestBuilder.php
library/Solarium/QueryType/MoreLikeThis/RequestBuilder.php
+1
-1
tests/Solarium/Tests/QueryType/MoreLikeThis/QueryTest.php
tests/Solarium/Tests/QueryType/MoreLikeThis/QueryTest.php
+13
-0
tests/Solarium/Tests/QueryType/MoreLikeThis/RequestBuilderTest.php
...arium/Tests/QueryType/MoreLikeThis/RequestBuilderTest.php
+2
-1
No files found.
library/Solarium/QueryType/MoreLikeThis/Query.php
View file @
2e3a1b13
...
...
@@ -70,6 +70,7 @@ class Query extends SelectQuery
'fields'
=>
'*,score'
,
'interestingTerms'
=>
'none'
,
'matchinclude'
=>
false
,
'matchoffset'
=>
0
,
'stream'
=>
false
,
'omitheader'
=>
true
,
);
...
...
@@ -174,6 +175,30 @@ class Query extends SelectQuery
return
$this
->
getOption
(
'matchinclude'
);
}
/**
* Set the mlt.match.offset parameter, which determines the which result from the query should be used for MLT
* For paging of MLT use setStart / setRows
*
* @see http://wiki.apache.org/solr/MoreLikeThisHandler#Params
*
* @param int $offset
* @return self Provides fluent interface
*/
public
function
setMatchOffset
(
$offset
)
{
return
$this
->
setOption
(
'matchoffset'
,
$offset
);
}
/**
* Get the mlt.match.offset parameter.
*
* @return int
*/
public
function
getMatchOffset
()
{
return
$this
->
getOption
(
'matchoffset'
);
}
/**
* Set MLT fields option
*
...
...
library/Solarium/QueryType/MoreLikeThis/RequestBuilder.php
View file @
2e3a1b13
...
...
@@ -63,7 +63,7 @@ class RequestBuilder extends SelectRequestBuilder
// add mlt params to request
$request
->
addParam
(
'mlt.interestingTerms'
,
$query
->
getInterestingTerms
());
$request
->
addParam
(
'mlt.match.include'
,
$query
->
getMatchInclude
());
$request
->
addParam
(
'mlt.match.offset'
,
$query
->
get
Star
t
());
$request
->
addParam
(
'mlt.match.offset'
,
$query
->
get
MatchOffse
t
());
$request
->
addParam
(
'mlt.fl'
,
implode
(
','
,
$query
->
getMltFields
()));
$request
->
addParam
(
'mlt.mintf'
,
$query
->
getMinimumTermFrequency
());
$request
->
addParam
(
'mlt.mindf'
,
$query
->
getMinimumDocumentFrequency
());
...
...
tests/Solarium/Tests/QueryType/MoreLikeThis/QueryTest.php
View file @
2e3a1b13
...
...
@@ -439,6 +439,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
)
),
),
'matchoffset'
=>
15
,
'resultclass'
=>
'MyResultClass'
,
'documentclass'
=>
'MyDocumentClass'
,
);
...
...
@@ -451,6 +452,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$config
[
'start'
],
$query
->
getStart
());
$this
->
assertEquals
(
$config
[
'documentclass'
],
$query
->
getDocumentClass
());
$this
->
assertEquals
(
$config
[
'resultclass'
],
$query
->
getResultClass
());
$this
->
assertEquals
(
$config
[
'matchoffset'
],
$query
->
getMatchOffset
());
$this
->
assertEquals
(
'published:true'
,
$query
->
getFilterQuery
(
'pub'
)
->
getQuery
());
$this
->
assertEquals
(
'online:true'
,
$query
->
getFilterQuery
(
'online'
)
->
getQuery
());
...
...
@@ -664,6 +666,17 @@ class QueryTest extends \PHPUnit_Framework_TestCase
);
}
public
function
testSetAndGetMatchOffset
()
{
$value
=
20
;
$this
->
query
->
setMatchOffset
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
query
->
getMatchOffset
()
);
}
public
function
testSetAndGetMltFields
()
{
$value
=
'name,description'
;
...
...
tests/Solarium/Tests/QueryType/MoreLikeThis/RequestBuilderTest.php
View file @
2e3a1b13
...
...
@@ -58,6 +58,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
$this
->
query
->
setInterestingTerms
(
'test'
);
$this
->
query
->
setMatchInclude
(
true
);
$this
->
query
->
setStart
(
12
);
$this
->
query
->
setMatchOffset
(
15
);
$this
->
query
->
setMltFields
(
'description,name'
);
$this
->
query
->
setMinimumTermFrequency
(
1
);
$this
->
query
->
setMinimumDocumentFrequency
(
3
);
...
...
@@ -74,7 +75,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
array
(
'mlt.interestingTerms'
=>
'test'
,
'mlt.match.include'
=>
'true'
,
'mlt.match.offset'
=>
1
2
,
'mlt.match.offset'
=>
1
5
,
'mlt.fl'
=>
'description,name'
,
'mlt.mintf'
=>
1
,
'mlt.mindf'
=>
3
,
...
...
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