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
6cdc4983
Commit
6cdc4983
authored
Mar 01, 2014
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maximumscore filtering for groups improved to support different types of sorting
parent
7236f732
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
15 deletions
+72
-15
library/Solarium/Plugin/MinimumScoreFilter/QueryGroupResult.php
...y/Solarium/Plugin/MinimumScoreFilter/QueryGroupResult.php
+34
-5
library/Solarium/Plugin/MinimumScoreFilter/ValueGroupResult.php
...y/Solarium/Plugin/MinimumScoreFilter/ValueGroupResult.php
+34
-6
library/Solarium/QueryType/Select/Result/Grouping/QueryGroup.php
.../Solarium/QueryType/Select/Result/Grouping/QueryGroup.php
+2
-2
library/Solarium/QueryType/Select/Result/Grouping/ValueGroup.php
.../Solarium/QueryType/Select/Result/Grouping/ValueGroup.php
+2
-2
No files found.
library/Solarium/Plugin/MinimumScoreFilter/QueryGroupResult.php
View file @
6cdc4983
...
...
@@ -48,6 +48,21 @@ class QueryGroupResult extends StandardQueryGroupResult
*/
static
protected
$overallMaximumScore
;
/**
* @var string
*/
protected
$filterMode
;
/**
* @var float
*/
protected
$filterRatio
;
/**
* @var boolean
*/
protected
$filtered
=
false
;
/**
* Constructor
*
...
...
@@ -60,17 +75,31 @@ class QueryGroupResult extends StandardQueryGroupResult
*/
public
function
__construct
(
$matches
,
$numFound
,
$start
,
$maximumScore
,
$documents
,
$query
)
{
$this
->
filterMode
=
$query
->
getFilterMode
();
$this
->
filterRatio
=
$query
->
getFilterRatio
();
// Use the maximumScore of the first group as maximum for all groups
if
(
self
::
$overallMaximumScore
==
null
)
{
self
::
$overallMaximumScore
=
$maximumScore
;
}
parent
::
__construct
(
$matches
,
$numFound
,
$start
,
$maximumScore
,
$documents
,
$query
);
}
/**
* Get all documents, apply filter at first use
*
* @return array
*/
public
function
getDocuments
()
{
if
(
!
$this
->
filtered
)
{
$filter
=
new
Filter
;
$mode
=
$query
->
getFilterMode
(
);
$ratio
=
$query
->
getFilterRatio
()
;
$documents
=
$filter
->
filterDocuments
(
$documents
,
self
::
$overallMaximumScore
,
$ratio
,
$mode
);
$this
->
documents
=
$filter
->
filterDocuments
(
$this
->
documents
,
self
::
$overallMaximumScore
,
$this
->
filterRatio
,
$this
->
filterMode
);
$this
->
filtered
=
true
;
}
parent
::
__construct
(
$matches
,
$numFound
,
$start
,
$maximumScore
,
$documents
,
$query
)
;
return
$this
->
documents
;
}
}
library/Solarium/Plugin/MinimumScoreFilter/ValueGroupResult.php
View file @
6cdc4983
...
...
@@ -48,6 +48,21 @@ class ValueGroupResult extends StandardValueGroup
*/
static
protected
$overallMaximumScore
;
/**
* @var string
*/
protected
$filterMode
;
/**
* @var float
*/
protected
$filterRatio
;
/**
* @var boolean
*/
protected
$filtered
=
false
;
/**
* Constructor
*
...
...
@@ -59,18 +74,31 @@ class ValueGroupResult extends StandardValueGroup
*/
public
function
__construct
(
$value
,
$numFound
,
$start
,
$documents
,
$maximumScore
,
$query
)
{
$this
->
filterMode
=
$query
->
getFilterMode
();
$this
->
filterRatio
=
$query
->
getFilterRatio
();
// Use the maximumScore of the first group as maximum for all groups
if
(
self
::
$overallMaximumScore
==
null
)
{
if
(
$maximumScore
>
self
::
$overallMaximumScore
)
{
self
::
$overallMaximumScore
=
$maximumScore
;
}
$filter
=
new
Filter
;
$mode
=
$query
->
getFilterMode
();
$ratio
=
$query
->
getFilterRatio
();
$documents
=
$filter
->
filterDocuments
(
$documents
,
self
::
$overallMaximumScore
,
$ratio
,
$mode
);
parent
::
__construct
(
$value
,
$numFound
,
$start
,
$documents
);
}
/**
* Get all documents, apply filter at first use
*
* @return array
*/
public
function
getDocuments
()
{
if
(
!
$this
->
filtered
)
{
$filter
=
new
Filter
;
$this
->
documents
=
$filter
->
filterDocuments
(
$this
->
documents
,
self
::
$overallMaximumScore
,
$this
->
filterRatio
,
$this
->
filterMode
);
$this
->
filtered
=
true
;
}
return
$this
->
documents
;
}
}
library/Solarium/QueryType/Select/Result/Grouping/QueryGroup.php
View file @
6cdc4983
...
...
@@ -166,7 +166,7 @@ class QueryGroup implements \IteratorAggregate, \Countable
*/
public
function
getIterator
()
{
return
new
\ArrayIterator
(
$this
->
documents
);
return
new
\ArrayIterator
(
$this
->
getDocuments
()
);
}
/**
...
...
@@ -176,6 +176,6 @@ class QueryGroup implements \IteratorAggregate, \Countable
*/
public
function
count
()
{
return
count
(
$this
->
documents
);
return
count
(
$this
->
getDocuments
()
);
}
}
library/Solarium/QueryType/Select/Result/Grouping/ValueGroup.php
View file @
6cdc4983
...
...
@@ -164,7 +164,7 @@ class ValueGroup implements \IteratorAggregate, \Countable
*/
public
function
getIterator
()
{
return
new
\ArrayIterator
(
$this
->
documents
);
return
new
\ArrayIterator
(
$this
->
getDocuments
()
);
}
/**
...
...
@@ -174,6 +174,6 @@ class ValueGroup implements \IteratorAggregate, \Countable
*/
public
function
count
()
{
return
count
(
$this
->
documents
);
return
count
(
$this
->
getDocuments
()
);
}
}
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