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
b81e2892
Commit
b81e2892
authored
Jan 06, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for Solr join syntax in query helper
parent
2db071c4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
library/Solarium/Query/Helper.php
library/Solarium/Query/Helper.php
+19
-10
tests/Solarium/Query/HelperTest.php
tests/Solarium/Query/HelperTest.php
+8
-0
No files found.
library/Solarium/Query/Helper.php
View file @
b81e2892
...
@@ -110,7 +110,6 @@ class Solarium_Query_Helper
...
@@ -110,7 +110,6 @@ class Solarium_Query_Helper
* Example: rangeQuery('store', '45,-94', '46,-93')
* Example: rangeQuery('store', '45,-94', '46,-93')
* Returns: store:[45,-94 TO 46,-93]
* Returns: store:[45,-94 TO 46,-93]
*
*
* @static
* @param string $field
* @param string $field
* @param string $from
* @param string $from
* @param string $to
* @param string $to
...
@@ -131,7 +130,6 @@ class Solarium_Query_Helper
...
@@ -131,7 +130,6 @@ class Solarium_Query_Helper
*
*
* Find all entries within the distance of a certain point.
* Find all entries within the distance of a certain point.
*
*
* @static
* @param $pointX
* @param $pointX
* @param $pointY
* @param $pointY
* @param $field
* @param $field
...
@@ -158,7 +156,6 @@ class Solarium_Query_Helper
...
@@ -158,7 +156,6 @@ class Solarium_Query_Helper
* guaranteed to encompass all of the points of interest, but it may also
* guaranteed to encompass all of the points of interest, but it may also
* include other points that are slightly outside of the required distance.
* include other points that are slightly outside of the required distance.
*
*
* @static
* @param string $pointX
* @param string $pointX
* @param string $pointY
* @param string $pointY
* @param string $field
* @param string $field
...
@@ -186,7 +183,6 @@ class Solarium_Query_Helper
...
@@ -186,7 +183,6 @@ class Solarium_Query_Helper
* or combining the distance with the relevancy score,
* or combining the distance with the relevancy score,
* such as boosting by the inverse of the distance.
* such as boosting by the inverse of the distance.
*
*
* @static
* @param $pointX
* @param $pointX
* @param $pointY
* @param $pointY
* @param $field
* @param $field
...
@@ -203,7 +199,6 @@ class Solarium_Query_Helper
...
@@ -203,7 +199,6 @@ class Solarium_Query_Helper
/**
/**
* Render a qparser plugin call
* Render a qparser plugin call
*
*
* @static
* @param string $name
* @param string $name
* @param array $params
* @param array $params
* @return string
* @return string
...
@@ -211,7 +206,7 @@ class Solarium_Query_Helper
...
@@ -211,7 +206,7 @@ class Solarium_Query_Helper
public
function
qparser
(
$name
,
$params
=
array
())
public
function
qparser
(
$name
,
$params
=
array
())
{
{
$output
=
'{!'
.
$name
;
$output
=
'{!'
.
$name
;
foreach
(
$params
AS
$key
=>
$value
)
{
foreach
(
$params
as
$key
=>
$value
)
{
$output
.=
' '
.
$key
.
'='
.
$value
;
$output
.=
' '
.
$key
.
'='
.
$value
;
}
}
$output
.=
'}'
;
$output
.=
'}'
;
...
@@ -222,7 +217,6 @@ class Solarium_Query_Helper
...
@@ -222,7 +217,6 @@ class Solarium_Query_Helper
/**
/**
* Render a functionCall
* Render a functionCall
*
*
* @static
* @param string $name
* @param string $name
* @param array $params
* @param array $params
* @return string
* @return string
...
@@ -297,4 +291,19 @@ class Solarium_Query_Helper
...
@@ -297,4 +291,19 @@ class Solarium_Query_Helper
return
$value
;
return
$value
;
}
}
/**
* Render join localparams syntax
*
* @see http://wiki.apache.org/solr/Join
* @since 2.4.0
*
* @param $from
* @param $to
* @return string
*/
public
function
join
(
$from
,
$to
)
{
return
$this
->
qparser
(
'join'
,
array
(
'from'
=>
$from
,
'to'
=>
$to
));
}
}
}
\ No newline at end of file
tests/Solarium/Query/HelperTest.php
View file @
b81e2892
...
@@ -197,4 +197,12 @@ class Solarium_Query_HelperTest extends PHPUnit_Framework_TestCase
...
@@ -197,4 +197,12 @@ class Solarium_Query_HelperTest extends PHPUnit_Framework_TestCase
$this
->
_helper
->
assemble
(
'cat:%1% AND content:%2%'
,
array
(
'value1'
));
$this
->
_helper
->
assemble
(
'cat:%1% AND content:%2%'
,
array
(
'value1'
));
}
}
public
function
testJoin
()
{
$this
->
assertEquals
(
'{!join from=manu_id to=id}'
,
$this
->
_helper
->
join
(
'manu_id'
,
'id'
)
);
}
}
}
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