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
a90167e1
Commit
a90167e1
authored
Oct 21, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/2.2.0' into develop
parents
6542c720
cb45f8b7
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
84 additions
and
77 deletions
+84
-77
examples/1.1-check-solarium-and-ping.php
examples/1.1-check-solarium-and-ping.php
+3
-1
examples/2.1.3-filterquery.php
examples/2.1.3-filterquery.php
+1
-6
examples/2.1.5.1.1-facet-field.php
examples/2.1.5.1.1-facet-field.php
+1
-6
examples/2.1.5.1.2-facet-query.php
examples/2.1.5.1.2-facet-query.php
+1
-6
examples/2.1.5.1.3-facet-multiquery.php
examples/2.1.5.1.3-facet-multiquery.php
+1
-5
examples/2.1.5.1.4-facet-range.php
examples/2.1.5.1.4-facet-range.php
+1
-5
examples/2.1.5.9-spellcheck.php
examples/2.1.5.9-spellcheck.php
+1
-2
examples/2.1.6-helper-functions.php
examples/2.1.6-helper-functions.php
+3
-9
examples/2.4.1-analysis-document.php
examples/2.4.1-analysis-document.php
+2
-0
examples/2.4.2-analysis-field.php
examples/2.4.2-analysis-field.php
+2
-0
examples/4.1-api-usage.php
examples/4.1-api-usage.php
+2
-9
examples/4.3-extending-usage.php
examples/4.3-extending-usage.php
+2
-10
library/Solarium/Client/Adapter/ZendHttp.php
library/Solarium/Client/Adapter/ZendHttp.php
+1
-0
library/Solarium/Client/Request.php
library/Solarium/Client/Request.php
+10
-10
library/Solarium/Client/RequestBuilder/Ping.php
library/Solarium/Client/RequestBuilder/Ping.php
+2
-1
library/Solarium/Client/ResponseParser/Analysis/Field.php
library/Solarium/Client/ResponseParser/Analysis/Field.php
+1
-1
library/Solarium/Client/ResponseParser/Select/Component/FacetSet.php
...arium/Client/ResponseParser/Select/Component/FacetSet.php
+8
-2
library/Solarium/Client/ResponseParser/Select/Component/Spellcheck.php
...ium/Client/ResponseParser/Select/Component/Spellcheck.php
+13
-0
library/Solarium/Query/Select.php
library/Solarium/Query/Select.php
+2
-2
library/Solarium/Result/Analysis/Item.php
library/Solarium/Result/Analysis/Item.php
+19
-1
library/Solarium/Result/Ping.php
library/Solarium/Result/Ping.php
+1
-1
tests/Solarium/Client/Adapter/ZendHttpTest.php
tests/Solarium/Client/Adapter/ZendHttpTest.php
+7
-0
No files found.
examples/1.1-check-solarium-and-ping.php
View file @
a90167e1
...
...
@@ -14,8 +14,10 @@ $ping = $client->createPing();
// execute the ping query
try
{
$client
->
ping
(
$ping
);
$
result
=
$
client
->
ping
(
$ping
);
echo
'Ping query succesful'
;
echo
'<br/><pre>'
;
var_dump
(
$result
->
getData
());
}
catch
(
Solarium_Exception
$e
){
echo
'Ping query failed'
;
}
...
...
examples/2.1.3-filterquery.php
View file @
a90167e1
...
...
@@ -10,12 +10,7 @@ $client = new Solarium_Client($config);
$query
=
$client
->
createSelect
();
// create a filterquery
$fq
=
$query
->
createFilterQuery
();
$fq
->
setKey
(
'maxprice'
);
$fq
->
setQuery
(
'price:[1 TO 300]'
);
// add it to the query
$query
->
addFilterQuery
(
$fq
);
$query
->
createFilterQuery
(
'maxprice'
)
->
setQuery
(
'price:[1 TO 300]'
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/2.1.5.1.1-facet-field.php
View file @
a90167e1
...
...
@@ -13,12 +13,7 @@ $query = $client->createSelect();
$facetSet
=
$query
->
getFacetSet
();
// create a facet field instance and set options
$facet
=
$facetSet
->
createFacetField
();
$facet
->
setKey
(
'stock'
);
$facet
->
setField
(
'inStock'
);
// add the facet instance to the facetset
$facetSet
->
addFacet
(
$facet
);
$facetSet
->
createFacetField
(
'stock'
)
->
setField
(
'inStock'
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/2.1.5.1.2-facet-query.php
View file @
a90167e1
...
...
@@ -13,12 +13,7 @@ $query = $client->createSelect();
$facetSet
=
$query
->
getFacetSet
();
// create a facet query instance and set options
$facet
=
$facetSet
->
createFacetQuery
();
$facet
->
setKey
(
'stock'
);
$facet
->
setQuery
(
'inStock: true'
);
// add the facet instance to the facetset
$facetSet
->
addFacet
(
$facet
);
$facetSet
->
createFacetQuery
(
'stock'
)
->
setQuery
(
'inStock: true'
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/2.1.5.1.3-facet-multiquery.php
View file @
a90167e1
...
...
@@ -13,16 +13,12 @@ $query = $client->createSelect();
$facetSet
=
$query
->
getFacetSet
();
// create a facet query instance and set options
$facet
=
$facetSet
->
createFacetMultiQuery
();
$facet
->
setKey
(
'stock'
);
$facet
=
$facetSet
->
createFacetMultiQuery
(
'stock'
);
$facet
->
createQuery
(
'stock_pricecat1'
,
'inStock:true AND price:[1 TO 300]'
);
$facet
->
createQuery
(
'nostock_pricecat1'
,
'inStock:false AND price:[1 TO 300]'
);
$facet
->
createQuery
(
'stock_pricecat2'
,
'inStock:true AND price:[300 TO *]'
);
$facet
->
createQuery
(
'nostock_pricecat2'
,
'inStock:false AND price:[300 TO *]'
);
// add the facet instance to the facetset
$facetSet
->
addFacet
(
$facet
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/2.1.5.1.4-facet-range.php
View file @
a90167e1
...
...
@@ -13,16 +13,12 @@ $query = $client->createSelect();
$facetSet
=
$query
->
getFacetSet
();
// create a facet field instance and set options
$facet
=
$facetSet
->
createFacetRange
();
$facet
->
setKey
(
'priceranges'
);
$facet
=
$facetSet
->
createFacetRange
(
'priceranges'
);
$facet
->
setField
(
'price'
);
$facet
->
setStart
(
1
);
$facet
->
setGap
(
100
);
$facet
->
setEnd
(
1000
);
// add the facet instance to the facetset
$facetSet
->
addFacet
(
$facet
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/2.1.5.9-spellcheck.php
View file @
a90167e1
...
...
@@ -10,8 +10,7 @@ $client = new Solarium_Client($config);
$query
=
$client
->
createSelect
();
$query
->
setRows
(
0
);
// add distributed search settings
// see http://wiki.apache.org/solr/DistributedSearch#Distributed_Search_Example for setting up two solr instances
// add spellcheck settings
$spellcheck
=
$query
->
getSpellcheck
();
$spellcheck
->
setQuery
(
'delll ultrashar'
);
$spellcheck
->
setBuild
(
true
);
...
...
examples/2.1.6-helper-functions.php
View file @
a90167e1
...
...
@@ -11,16 +11,10 @@ $query = $client->createSelect();
$helper
=
$query
->
getHelper
();
// add a filterquery on a price range, using the helper to generate the range
$fqPrice
=
$query
->
createFilterQuery
();
$fqPrice
->
setKey
(
'price'
);
$fqPrice
->
setQuery
(
$helper
->
rangeQuery
(
'price'
,
10
,
300
));
$query
->
addFilterQuery
(
$fqPrice
);
$query
->
createFilterQuery
(
'price'
)
->
setQuery
(
$helper
->
rangeQuery
(
'price'
,
10
,
300
));
// add a filterquery to find products in a range of 5km, using the helper to generate the 'geofilt' filter
$fqRegion
=
$query
->
createFilterQuery
();
$fqRegion
->
setKey
(
'region'
);
$fqRegion
->
setQuery
(
$helper
->
geofilt
(
45.15
,
-
93.85
,
'store'
,
5
));
$query
->
addFilterQuery
(
$fqRegion
);
$query
->
createFilterQuery
(
'region'
)
->
setQuery
(
$helper
->
geofilt
(
45.15
,
-
93.85
,
'store'
,
5
));
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
@@ -38,7 +32,7 @@ foreach ($resultset as $document) {
{
// this converts multivalue fields to a comma-separated string
if
(
is_array
(
$value
))
$value
=
implode
(
', '
,
$value
);
echo
'<tr><th>'
.
$field
.
'</th><td>'
.
$value
.
'</td></tr>'
;
}
...
...
examples/2.4.1-analysis-document.php
View file @
a90167e1
...
...
@@ -62,6 +62,7 @@ foreach ($result as $document) {
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'Match: '
.
var_export
(
$result
->
getMatch
(),
true
)
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
...
...
@@ -82,6 +83,7 @@ foreach ($result as $document) {
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'Match: '
.
var_export
(
$result
->
getMatch
(),
true
)
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
...
...
examples/2.4.2-analysis-field.php
View file @
a90167e1
...
...
@@ -42,6 +42,7 @@ foreach ($results as $result) {
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'Match: '
.
var_export
(
$result
->
getMatch
(),
true
)
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
...
...
@@ -62,6 +63,7 @@ foreach ($results as $result) {
echo
'Position: '
.
$result
->
getPosition
()
.
'<br/>'
;
echo
'Position history: '
.
implode
(
', '
,
$result
->
getPositionHistory
())
.
'<br/>'
;
echo
'Type: '
.
htmlspecialchars
(
$result
->
getType
())
.
'<br/>'
;
echo
'Match: '
.
var_export
(
$result
->
getMatch
(),
true
)
.
'<br/>'
;
echo
'-----------<br/>'
;
}
}
...
...
examples/4.1-api-usage.php
View file @
a90167e1
...
...
@@ -16,18 +16,11 @@ $query->setFields(array('id','name','price'));
$query
->
addSort
(
'price'
,
Solarium_Query_Select
::
SORT_ASC
);
// create a filterquery using the API
$fq
=
$query
->
createFilterQuery
();
$fq
->
setKey
(
'maxprice'
);
$fq
->
setQuery
(
'price:[1 TO 300]'
);
// and add it to the query
$query
->
addFilterQuery
(
$fq
);
$fq
=
$query
->
createFilterQuery
(
'maxprice'
)
->
setQuery
(
'price:[1 TO 300]'
);
// create a facet field instance and set options using the API
$facetSet
=
$query
->
getFacetSet
();
$facet
=
$facetSet
->
createFacetField
();
$facet
->
setKey
(
'stock'
);
$facet
->
setField
(
'inStock'
);
$facetSet
->
addFacet
(
$facet
);
$facet
=
$facetSet
->
createFacetField
(
'stock'
)
->
setField
(
'inStock'
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/4.3-extending-usage.php
View file @
a90167e1
...
...
@@ -19,10 +19,7 @@ class ProductQuery extends Solarium_Query_Select{
// create a facet field instance and set options
$facetSet
=
$this
->
getFacetSet
();
$facet
=
$facetSet
->
createFacetField
();
$facet
->
setKey
(
'stock'
);
$facet
->
setField
(
'inStock'
);
$facetSet
->
addFacet
(
$facet
);
$facetSet
->
createFacetField
(
'stock'
)
->
setField
(
'inStock'
);
}
}
...
...
@@ -36,12 +33,7 @@ class ProductPriceLimitedQuery extends ProductQuery{
parent
::
_init
();
// create a filterquery
$fq
=
$this
->
createFilterQuery
();
$fq
->
setKey
(
'maxprice'
);
$fq
->
setQuery
(
'price:[1 TO 300]'
);
// and add it
$this
->
addFilterQuery
(
$fq
);
$this
->
createFilterQuery
(
'maxprice'
)
->
setQuery
(
'price:[1 TO 300]'
);
}
}
...
...
library/Solarium/Client/Adapter/ZendHttp.php
View file @
a90167e1
...
...
@@ -154,6 +154,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
$client
->
setMethod
(
$request
->
getMethod
());
$client
->
setUri
(
$this
->
getBaseUri
()
.
$request
->
getUri
());
$client
->
setHeaders
(
$request
->
getHeaders
());
$client
->
setRawData
(
$request
->
getRawData
());
$response
=
$client
->
request
();
...
...
library/Solarium/Client/Request.php
View file @
a90167e1
...
...
@@ -48,21 +48,21 @@ class Solarium_Client_Request extends Solarium_Configurable
/**
* Request GET method
*/
const
METHOD_GET
=
'
get
'
;
const
METHOD_GET
=
'
GET
'
;
/**
* Request POST method
*/
const
METHOD_POST
=
'
post
'
;
const
METHOD_POST
=
'
POST
'
;
/**
* Request HEAD method
*/
const
METHOD_HEAD
=
'
head
'
;
const
METHOD_HEAD
=
'
HEAD
'
;
/**
* Default options
*
*
* @var array
*/
protected
$_options
=
array
(
...
...
@@ -73,7 +73,7 @@ class Solarium_Client_Request extends Solarium_Configurable
* Request headers
*/
protected
$_headers
=
array
();
/**
* Request params
*
...
...
@@ -202,7 +202,7 @@ class Solarium_Client_Request extends Solarium_Configurable
* unless you set the overwrite param to true.
*
* Empty params are not added to the request. If you want to empty a param disable it you should use
* remove param instead.
* remove param instead.
*
* @param string $key
* @param string|array $value
...
...
@@ -261,7 +261,7 @@ class Solarium_Client_Request extends Solarium_Configurable
/**
* Clear all request params
*
*
* @return Solarium_Client_Request
*/
public
function
clearParams
()
...
...
@@ -326,7 +326,7 @@ class Solarium_Client_Request extends Solarium_Configurable
public
function
addHeader
(
$value
)
{
$this
->
_headers
[]
=
$value
;
return
$this
;
}
...
...
@@ -347,7 +347,7 @@ class Solarium_Client_Request extends Solarium_Configurable
/**
* Clear all request headers
*
*
* @return Solarium_Client_Request
*/
public
function
clearHeaders
()
...
...
@@ -372,7 +372,7 @@ class Solarium_Client_Request extends Solarium_Configurable
$queryString
);
}
return
$this
->
getHandler
()
.
'?'
.
$queryString
;
}
}
\ No newline at end of file
library/Solarium/Client/RequestBuilder/Ping.php
View file @
a90167e1
...
...
@@ -55,7 +55,8 @@ class Solarium_Client_RequestBuilder_Ping extends Solarium_Client_RequestBuilder
{
$request
=
new
Solarium_Client_Request
;
$request
->
setHandler
(
$query
->
getHandler
());
$request
->
setMethod
(
Solarium_Client_Request
::
METHOD_HEAD
);
$request
->
setMethod
(
Solarium_Client_Request
::
METHOD_GET
);
$request
->
addParam
(
'wt'
,
'json'
);
return
$request
;
}
...
...
library/Solarium/Client/ResponseParser/Analysis/Field.php
View file @
a90167e1
...
...
@@ -100,7 +100,7 @@ class Solarium_Client_ResponseParser_Analysis_Field extends Solarium_Client_Resp
foreach
(
$fieldData
as
$typeKey
=>
$typeData
)
{
// fix for extra level for key fields
if
(
count
(
$typeData
)
==
1
){
if
(
count
(
$typeData
)
==
1
)
{
$typeData
=
current
(
$typeData
);
}
...
...
library/Solarium/Client/ResponseParser/Select/Component/FacetSet.php
View file @
a90167e1
...
...
@@ -171,12 +171,18 @@ class Solarium_Client_ResponseParser_Select_Component_FacetSet
if
(
isset
(
$data
[
'facet_counts'
][
'facet_ranges'
][
$key
]))
{
$data
=
$data
[
'facet_counts'
][
'facet_ranges'
][
$key
];
$before
=
(
isset
(
$data
[
'before'
]))
?
$data
[
'before'
]
:
null
;
$after
=
(
isset
(
$data
[
'after'
]))
?
$data
[
'after'
]
:
null
;
$between
=
(
isset
(
$data
[
'between'
]))
?
$data
[
'between'
]
:
null
;
return
new
Solarium_Result_Select_Facet_Range
(
$data
[
'counts'
],
$before
,
$after
,
$between
);
$offset
=
0
;
$counts
=
array
();
while
(
isset
(
$data
[
'counts'
][
$offset
])
&&
isset
(
$data
[
'counts'
][
$offset
+
1
]))
{
$counts
[
$data
[
'counts'
][
$offset
]]
=
$data
[
'counts'
][
$offset
+
1
];
$offset
+=
2
;
}
return
new
Solarium_Result_Select_Facet_Range
(
$counts
,
$before
,
$after
,
$between
);
}
}
...
...
library/Solarium/Client/ResponseParser/Select/Component/Spellcheck.php
View file @
a90167e1
...
...
@@ -93,6 +93,12 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
}
}
/**
* Parse collation data into a result object
*
* @param array $values
* @return Solarium_Result_Select_Spellcheck_Collation
*/
protected
function
_parseCollation
(
$values
)
{
if
(
is_string
(
$values
))
{
...
...
@@ -141,6 +147,13 @@ class Solarium_Client_ResponseParser_Select_Component_Spellcheck
}
}
/**
* Parse suggestion data into a result object
*
* @param string $key
* @param array $value
* @return Solarium_Result_Select_Spellcheck_Suggestion
*/
protected
function
_parseSuggestion
(
$key
,
$value
)
{
$numFound
=
(
isset
(
$value
[
'numFound'
]))
?
$value
[
'numFound'
]
:
null
;
...
...
library/Solarium/Query/Select.php
View file @
a90167e1
...
...
@@ -853,7 +853,7 @@ class Solarium_Query_Select extends Solarium_Query
return
$this
->
getComponent
(
Solarium_Query_Select
::
COMPONENT_GROUPING
,
true
);
}
/*
/*
*
* Get a spellcheck component instance
*
* This is a convenience method that maps presets to getComponent
...
...
@@ -865,7 +865,7 @@ class Solarium_Query_Select extends Solarium_Query
return
$this
->
getComponent
(
Solarium_Query_Select
::
COMPONENT_SPELLCHECK
,
true
);
}
/*
/*
*
* Get a DistributedSearch component instance
*
* This is a convenience method that maps presets to getComponent
...
...
library/Solarium/Result/Analysis/Item.php
View file @
a90167e1
...
...
@@ -80,6 +80,10 @@ class Solarium_Result_Analysis_Item
*/
protected
$_type
;
/**
* @var boolean
*/
protected
$_match
=
false
;
/**
* Constructor
...
...
@@ -98,6 +102,10 @@ class Solarium_Result_Analysis_Item
if
(
isset
(
$analysis
[
'raw_text'
]))
{
$this
->
_rawText
=
$analysis
[
'raw_text'
];
}
if
(
isset
(
$analysis
[
'match'
]))
{
$this
->
_match
=
$analysis
[
'match'
];
}
}
/**
...
...
@@ -154,7 +162,7 @@ class Solarium_Result_Analysis_Item
/**
* Get position history value
*
*
* @return array
*/
public
function
getPositionHistory
()
...
...
@@ -172,4 +180,14 @@ class Solarium_Result_Analysis_Item
return
$this
->
_type
;
}
/**
* Get match value
*
* @return boolean
*/
public
function
getMatch
()
{
return
$this
->
_match
;
}
}
\ No newline at end of file
library/Solarium/Result/Ping.php
View file @
a90167e1
...
...
@@ -45,7 +45,7 @@
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Ping
class
Solarium_Result_Ping
extends
Solarium_Result
{
/**
...
...
tests/Solarium/Client/Adapter/ZendHttpTest.php
View file @
a90167e1
...
...
@@ -88,10 +88,14 @@ class Solarium_Client_Adapter_ZendHttpTest extends PHPUnit_Framework_TestCase
$rawData
=
'xyz'
;
$responseData
=
'abc'
;
$handler
=
'myhandler'
;
$headers
=
array
(
'Content-Type: application/x-www-form-urlencoded'
);
$request
=
new
Solarium_Client_Request
();
$request
->
setMethod
(
$method
);
$request
->
setHandler
(
$handler
);
$request
->
setHeaders
(
$headers
);
$request
->
setRawData
(
$rawData
);
$response
=
new
Zend_Http_Response
(
200
,
array
(
'status'
=>
'HTTP 1.1 200 OK'
),
$responseData
);
...
...
@@ -103,6 +107,9 @@ class Solarium_Client_Adapter_ZendHttpTest extends PHPUnit_Framework_TestCase
$mock
->
expects
(
$this
->
once
())
->
method
(
'setUri'
)
->
with
(
$this
->
equalTo
(
'http://127.0.0.1:8983/solr/myhandler?'
));
$mock
->
expects
(
$this
->
once
())
->
method
(
'setHeaders'
)
->
with
(
$this
->
equalTo
(
$headers
));
$mock
->
expects
(
$this
->
once
())
->
method
(
'setRawData'
)
->
with
(
$this
->
equalTo
(
$rawData
));
...
...
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