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
62b3fbd3
Commit
62b3fbd3
authored
Jun 04, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
merge changes into nextgen
parents
787811dc
2fb0fe4c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
722 additions
and
11 deletions
+722
-11
library/Solarium/Query/Select/Query/Component/EDisMax.php
library/Solarium/Query/Select/Query/Component/EDisMax.php
+222
-0
library/Solarium/Query/Select/Query/Query.php
library/Solarium/Query/Select/Query/Query.php
+18
-0
library/Solarium/Query/Select/RequestBuilder/Component/EDisMax.php
...olarium/Query/Select/RequestBuilder/Component/EDisMax.php
+86
-0
library/Solarium/Query/Select/RequestBuilder/Component/FacetSet.php
...larium/Query/Select/RequestBuilder/Component/FacetSet.php
+1
-1
library/Solarium/Query/Select/ResponseParser/Component/Spellcheck.php
...rium/Query/Select/ResponseParser/Component/Spellcheck.php
+3
-3
library/Solarium/Query/Select/Result/Spellcheck/Result.php
library/Solarium/Query/Select/Result/Spellcheck/Result.php
+28
-7
tests/Solarium/Client/RequestBuilder/Select/Component/EDisMaxTest.php
...um/Client/RequestBuilder/Select/Component/EDisMaxTest.php
+84
-0
tests/Solarium/Tests/Query/Select/Query/Component/EDisMaxTest.php
...larium/Tests/Query/Select/Query/Component/EDisMaxTest.php
+268
-0
tests/Solarium/Tests/Query/Select/RequestBuilder/Component/FacetSetTest.php
...ts/Query/Select/RequestBuilder/Component/FacetSetTest.php
+1
-0
tests/Solarium/Tests/Query/Select/RequestBuilder/RequestBuilderTest.php
.../Tests/Query/Select/RequestBuilder/RequestBuilderTest.php
+11
-0
No files found.
library/Solarium/Query/Select/Query/Component/EDisMax.php
0 → 100644
View file @
62b3fbd3
<?php
/**
* Copyright 2012 Marc Morera. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2012 Marc Morera <yuhu@mmoreram.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
*/
/**
* EDisMax component
*
* @link http://wiki.apache.org/solr/ExtendedDisMax
*
* @package Solarium
* @subpackage Query
*/
class
Solarium_Query_Select_Component_EDisMax
extends
Solarium_Query_Select_Component_DisMax
{
/**
* Component type
*
* @var string
*/
protected
$_type
=
Solarium_Query_Select
::
COMPONENT_EDISMAX
;
/**
* Default options
*
* @var array
*/
protected
$_options
=
array
(
'queryparser'
=>
'edismax'
,
);
/**
* Set BoostFunctionsMult option
*
* Functions (with optional boosts) that will be included in the
* user's query to influence the score by multiplying its value.
*
* Format is: "funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2"
*
* @param string $boostFunctionsMult
* @return Solarium_Query_Select_Component_EDisMax Provides fluent interface
*/
public
function
setBoostFunctionsMult
(
$boostFunctionsMult
)
{
return
$this
->
_setOption
(
'boostfunctionsmult'
,
$boostFunctionsMult
);
}
/**
* Get BoostFunctionsMult option
*
* @return string|null
*/
public
function
getBoostFunctionsMult
()
{
return
$this
->
getOption
(
'boostfunctionsmult'
);
}
/**
* Set PhraseFields option
*
* As with 'pf' but chops the input into bi-grams,
* e.g. "the brown fox jumped" is queried as "the brown" "brown fox" "fox jumped"
*
* Format is: "fieldA^1.0 fieldB^2.2 fieldC^3.5"
*
* @param string $phraseBigramFields
* @return Solarium_Query_Select_Component_EDisMax Provides fluent interface
*/
public
function
setPhraseBigramFields
(
$phraseBigramFields
)
{
return
$this
->
_setOption
(
'phrasebigramfields'
,
$phraseBigramFields
);
}
/**
* Get PhraseBigramFields option
*
* @return string|null
*/
public
function
getPhraseBigramFields
()
{
return
$this
->
getOption
(
'phrasebigramfields'
);
}
/**
* Set PhraseBigramSlop option
*
* As with 'ps' but sets default slop factor for 'pf2'.
* If not specified, 'ps' will be used.
*
* @param string $phraseBigramSlop
* @return Solarium_Query_Select_Component_EDisMax Provides fluent interface
*/
public
function
setPhraseBigramSlop
(
$phraseBigramSlop
)
{
return
$this
->
_setOption
(
'phrasebigramslop'
,
$phraseBigramSlop
);
}
/**
* Get PhraseBigramSlop option
*
* @return string|null
*/
public
function
getPhraseBigramSlop
()
{
return
$this
->
getOption
(
'phrasebigramslop'
);
}
/**
* Set PhraseFields option
*
* As with 'pf' but chops the input into tri-grams,
* e.g. "the brown fox jumped" is queried as "the brown fox" "brown fox jumped"
*
* Format is: "fieldA^1.0 fieldB^2.2 fieldC^3.5"
*
* @param string $phraseTrigramFields
* @return Solarium_Query_Select_Component_EDisMax Provides fluent interface
*/
public
function
setPhraseTrigramFields
(
$phraseTrigramFields
)
{
return
$this
->
_setOption
(
'phrasetrigramfields'
,
$phraseTrigramFields
);
}
/**
* Get PhraseTrigramFields option
*
* @return string|null
*/
public
function
getPhraseTrigramFields
()
{
return
$this
->
getOption
(
'phrasetrigramfields'
);
}
/**
* Set PhraseTrigramSlop option
*
* As with 'ps' but sets default slop factor for 'pf3'.
* If not specified, 'ps' will be used.
*
* @param string $phraseTrigramSlop
* @return Solarium_Query_Select_Component_EDisMax Provides fluent interface
*/
public
function
setPhraseTrigramSlop
(
$phraseTrigramSlop
)
{
return
$this
->
_setOption
(
'phrasetrigramslop'
,
$phraseTrigramSlop
);
}
/**
* Get PhraseTrigramSlop option
*
* @return string|null
*/
public
function
getPhraseTrigramSlop
()
{
return
$this
->
getOption
(
'phrasetrigramslop'
);
}
/**
* Set UserFields option
*
* Specifies which schema fields the end user shall be allowed to query for explicitly.
* This parameter supports wildcards.
*
* The default is to allow all fields, equivalent to &uf=*.
* To allow only title field, use &uf=title, to allow title and all fields ending with _s, use &uf=title *_s.
* To allow all fields except title, use &uf=* -title. To disallow all fielded searches, use &uf=-*.
* The uf parameter was introduced in Solr3.6
*
* @param string $userFields
* @return Solarium_Query_Select_Component_EDisMax Provides fluent interface
*/
public
function
setUserFields
(
$userFields
)
{
return
$this
->
_setOption
(
'userfields'
,
$userFields
);
}
/**
* Get UserFields option
*
* @return string|null
*/
public
function
getUserFields
()
{
return
$this
->
getOption
(
'userfields'
);
}
}
\ No newline at end of file
library/Solarium/Query/Select/Query/Query.php
View file @
62b3fbd3
...
@@ -83,6 +83,11 @@ class Query extends BaseQuery
...
@@ -83,6 +83,11 @@ class Query extends BaseQuery
*/
*/
const
COMPONENT_DISMAX
=
'dismax'
;
const
COMPONENT_DISMAX
=
'dismax'
;
/**
* Query component dismax
*/
const
COMPONENT_EDISMAX
=
'edismax'
;
/**
/**
* Query component morelikethis
* Query component morelikethis
*/
*/
...
@@ -141,6 +146,7 @@ class Query extends BaseQuery
...
@@ -141,6 +146,7 @@ class Query extends BaseQuery
protected
$componentTypes
=
array
(
protected
$componentTypes
=
array
(
self
::
COMPONENT_FACETSET
=>
'Solarium\Query\Select\Query\Component\FacetSet'
,
self
::
COMPONENT_FACETSET
=>
'Solarium\Query\Select\Query\Component\FacetSet'
,
self
::
COMPONENT_DISMAX
=>
'Solarium\Query\Select\Query\Component\DisMax'
,
self
::
COMPONENT_DISMAX
=>
'Solarium\Query\Select\Query\Component\DisMax'
,
self
::
COMPONENT_EDISMAX
=>
'Solarium\Query\Select\Query\Component\EdisMax'
,
self
::
COMPONENT_MORELIKETHIS
=>
'Solarium\Query\Select\Query\Component\MoreLikeThis'
,
self
::
COMPONENT_MORELIKETHIS
=>
'Solarium\Query\Select\Query\Component\MoreLikeThis'
,
self
::
COMPONENT_HIGHLIGHTING
=>
'Solarium\Query\Select\Query\Component\Highlighting\Highlighting'
,
self
::
COMPONENT_HIGHLIGHTING
=>
'Solarium\Query\Select\Query\Component\Highlighting\Highlighting'
,
self
::
COMPONENT_GROUPING
=>
'Solarium\Query\Select\Query\Component\Grouping'
,
self
::
COMPONENT_GROUPING
=>
'Solarium\Query\Select\Query\Component\Grouping'
,
...
@@ -882,6 +888,18 @@ class Query extends BaseQuery
...
@@ -882,6 +888,18 @@ class Query extends BaseQuery
return
$this
->
getComponent
(
self
::
COMPONENT_DISMAX
,
true
);
return
$this
->
getComponent
(
self
::
COMPONENT_DISMAX
,
true
);
}
}
/**
* Get a EdisMax component instance
*
* This is a convenience method that maps presets to getComponent
*
* @return Component\EdisMax
*/
public
function
getEDisMax
()
{
return
$this
->
getComponent
(
self
::
COMPONENT_EDISMAX
,
true
);
}
/**
/**
* Get a highlighting component instance
* Get a highlighting component instance
*
*
...
...
library/Solarium/Query/Select/RequestBuilder/Component/EDisMax.php
0 → 100644
View file @
62b3fbd3
<?php
/**
* Copyright 2012 Marc Morera. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2012 Marc Morera <yuhu@mmoreram.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
*/
/**
* @namespace
*/
namespace
Solarium\Query\Select\Query\Component
;
use
Solarium\Query\Select\Query\Query
as
SelectQuery
;
use
Solarium\Query\Select\RequestBuilder\Component\DisMax
as
RequestBuilder
;
/**
* Add select component edismax to the request
*
* @package Solarium
* @subpackage Client
*/
class
EdisMax
{
/**
* Add request settings for EDismax
*
* @param Solarium_Query_Select_Component_EDismax $component
* @param Solarium_Client_Request $request
* @return Solarium_Client_Request
*/
public
function
buildComponent
(
$component
,
$request
)
{
// enable edismax
$request
->
addParam
(
'defType'
,
$component
->
getQueryParser
());
$request
->
addParam
(
'q.alt'
,
$component
->
getQueryAlternative
());
$request
->
addParam
(
'qf'
,
$component
->
getQueryFields
());
$request
->
addParam
(
'mm'
,
$component
->
getMinimumMatch
());
$request
->
addParam
(
'pf'
,
$component
->
getPhraseFields
());
$request
->
addParam
(
'ps'
,
$component
->
getPhraseSlop
());
$request
->
addParam
(
'pf2'
,
$component
->
getPhraseBigramFields
());
$request
->
addParam
(
'ps2'
,
$component
->
getPhraseBigramSlop
());
$request
->
addParam
(
'pf3'
,
$component
->
getPhraseTrigramFields
());
$request
->
addParam
(
'ps3'
,
$component
->
getPhraseTrigramSlop
());
$request
->
addParam
(
'qs'
,
$component
->
getQueryPhraseSlop
());
$request
->
addParam
(
'tie'
,
$component
->
getTie
());
$request
->
addParam
(
'bq'
,
$component
->
getBoostQuery
());
$request
->
addParam
(
'bf'
,
$component
->
getBoostFunctions
());
$request
->
addParam
(
'boost'
,
$component
->
getBoostFunctionsMult
());
$request
->
addParam
(
'uf'
,
$component
->
getUserFields
());
return
$request
;
}
}
\ No newline at end of file
library/Solarium/Query/Select/RequestBuilder/Component/FacetSet.php
View file @
62b3fbd3
...
@@ -190,7 +190,7 @@ class FacetSet extends RequestBuilder
...
@@ -190,7 +190,7 @@ class FacetSet extends RequestBuilder
}
}
}
}
if
(
null
!==
$facet
->
get
Other
())
{
if
(
null
!==
$facet
->
get
Include
())
{
$include
=
explode
(
','
,
$facet
->
getInclude
());
$include
=
explode
(
','
,
$facet
->
getInclude
());
foreach
(
$include
AS
$includeValue
)
{
foreach
(
$include
AS
$includeValue
)
{
$request
->
addParam
(
"f.
$field
.facet.range.include"
,
trim
(
$includeValue
));
$request
->
addParam
(
"f.
$field
.facet.range.include"
,
trim
(
$includeValue
));
...
...
library/Solarium/Query/Select/ResponseParser/Component/Spellcheck.php
View file @
62b3fbd3
...
@@ -68,7 +68,7 @@ class Spellcheck
...
@@ -68,7 +68,7 @@ class Spellcheck
$suggestions
=
array
();
$suggestions
=
array
();
$correctlySpelled
=
null
;
$correctlySpelled
=
null
;
$collation
=
null
;
$collation
s
=
array
()
;
$index
=
0
;
$index
=
0
;
while
(
isset
(
$spellcheckResults
[
$index
])
&&
isset
(
$spellcheckResults
[
$index
+
1
]))
{
while
(
isset
(
$spellcheckResults
[
$index
])
&&
isset
(
$spellcheckResults
[
$index
+
1
]))
{
...
@@ -80,7 +80,7 @@ class Spellcheck
...
@@ -80,7 +80,7 @@ class Spellcheck
$correctlySpelled
=
$value
;
$correctlySpelled
=
$value
;
break
;
break
;
case
'collation'
:
case
'collation'
:
$collation
=
$this
->
parseCollation
(
$value
);
$collation
s
[]
=
$this
->
_
parseCollation
(
$value
);
break
;
break
;
default
:
default
:
$suggestions
[]
=
$this
->
parseSuggestion
(
$key
,
$value
);
$suggestions
[]
=
$this
->
parseSuggestion
(
$key
,
$value
);
...
@@ -89,7 +89,7 @@ class Spellcheck
...
@@ -89,7 +89,7 @@ class Spellcheck
$index
+=
2
;
$index
+=
2
;
}
}
return
new
SpellcheckResult\Result
(
$suggestions
,
$collation
,
$correctlySpelled
);
return
new
SpellcheckResult\Result
(
$suggestions
,
$collation
s
,
$correctlySpelled
);
}
else
{
}
else
{
return
null
;
return
null
;
}
}
...
...
library/Solarium/Query/Select/Result/Spellcheck/Result.php
View file @
62b3fbd3
...
@@ -52,11 +52,11 @@ class Result implements \IteratorAggregate, \Countable
...
@@ -52,11 +52,11 @@ class Result implements \IteratorAggregate, \Countable
protected
$suggestions
;
protected
$suggestions
;
/**
/**
* Collation object
* Collation object
array
*
*
* @var
Collation
* @var
array
*/
*/
protected
$collation
;
protected
$collation
s
;
/**
/**
* Correctly spelled?
* Correctly spelled?
...
@@ -73,21 +73,42 @@ class Result implements \IteratorAggregate, \Countable
...
@@ -73,21 +73,42 @@ class Result implements \IteratorAggregate, \Countable
* @param boolean $correctlySpelled
* @param boolean $correctlySpelled
* @return void
* @return void
*/
*/
public
function
__construct
(
$suggestions
,
$collation
,
$correctlySpelled
)
public
function
__construct
(
$suggestions
,
$collation
s
,
$correctlySpelled
)
{
{
$this
->
suggestions
=
$suggestions
;
$this
->
suggestions
=
$suggestions
;
$this
->
collation
=
$collation
;
$this
->
collation
s
=
$collations
;
$this
->
correctlySpelled
=
$correctlySpelled
;
$this
->
correctlySpelled
=
$correctlySpelled
;
}
}
/**
/**
* Get the collation result
* Get the collation result
*
*
* @param int $key
* @return Collation
* @return Collation
*/
*/
public
function
getCollation
()
public
function
getCollation
(
$key
=
null
)
{
$nrOfCollations
=
count
(
$this
->
collations
);
if
(
$nrOfCollations
==
0
)
{
return
null
;
}
else
{
if
(
$key
===
null
)
{
$key
=
$nrOfCollations
-
1
;
// for backwards compatibility
}
return
$this
->
collations
[
$key
];
}
}
/**
* Get all collations
*
* @return array
*/
public
function
getCollations
()
{
{
return
$this
->
collation
;
return
$this
->
collation
s
;
}
}
/**
/**
...
...
tests/Solarium/Client/RequestBuilder/Select/Component/EDisMaxTest.php
0 → 100644
View file @
62b3fbd3
<?php
/**
* Copyright 2012 Marc Morera. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Client_RequestBuilder_Select_Component_EDisMaxTest
extends
PHPUnit_Framework_TestCase
{
public
function
testBuildComponent
()
{
$builder
=
new
Solarium_Client_RequestBuilder_Select_Component_EDisMax
;
$request
=
new
Solarium_Client_Request
();
$component
=
new
Solarium_Query_Select_Component_EDisMax
();
$component
->
setQueryParser
(
'dummyparser'
);
$component
->
setQueryAlternative
(
'test'
);
$component
->
setQueryFields
(
'content,name'
);
$component
->
setMinimumMatch
(
'75%'
);
$component
->
setPhraseFields
(
'content,description'
);
$component
->
setPhraseSlop
(
1
);
$component
->
setPhraseBigramFields
(
'content,description,category'
);
$component
->
setPhraseBigramSlop
(
4
);
$component
->
setPhraseTrigramFields
(
'content2,date,subcategory'
);
$component
->
setPhraseTrigramSlop
(
3
);
$component
->
setQueryPhraseSlop
(
2
);
$component
->
setTie
(
0.5
);
$component
->
setBoostQuery
(
'cat:1'
);
$component
->
setBoostFunctions
(
'functionX(price)'
);
$component
->
setBoostFunctionsMult
(
'functionX(date)'
);
$component
->
setUserFields
(
'title *_s'
);
$request
=
$builder
->
buildComponent
(
$component
,
$request
);
$this
->
assertEquals
(
array
(
'defType'
=>
'dummyparser'
,
'q.alt'
=>
'test'
,
'qf'
=>
'content,name'
,
'mm'
=>
'75%'
,
'pf'
=>
'content,description'
,
'ps'
=>
1
,
'pf2'
=>
'content,description,category'
,
'ps2'
=>
4
,
'pf3'
=>
'content2,date,subcategory'
,
'ps3'
=>
3
,
'qs'
=>
2
,
'tie'
=>
0.5
,
'bq'
=>
'cat:1'
,
'bf'
=>
'functionX(price)'
,
'boost'
=>
'functionX(date)'
,
'uf'
=>
'title *_s'
,
),
$request
->
getParams
()
);
}
}
\ No newline at end of file
tests/Solarium/Tests/Query/Select/Query/Component/EDisMaxTest.php
0 → 100644
View file @
62b3fbd3
<?php
/**
* Copyright 2012 Marc Morera. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class
Solarium_Query_Select_Component_EDisMaxTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_EDisMax
*/
protected
$_eDisMax
;
public
function
setUp
()
{
$this
->
_eDisMax
=
new
Solarium_Query_Select_Component_EDisMax
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'queryparser'
=>
'edismax'
,
'queryalternative'
=>
'*:*'
,
'queryfields'
=>
'title^2.0 description'
,
'minimummatch'
=>
'2.0'
,
'phrasefields'
=>
'title^2.0 description^3.5'
,
'phraseslop'
=>
2
,
'phrasebigramfields'
=>
'description^1.3 date^4.3 field_text2^1.3'
,
'phrasebigramslop'
=>
3
,
'phrasetrigramfields'
=>
'datetime^4 field1^5 myotherfield^9'
,
'phrasetrigramslop'
=>
5
,
'queryphraseslop'
=>
4
,
'tie'
=>
2.1
,
'boostquery'
=>
'cat:1^3'
,
'boostfunctions'
=>
'funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2'
,
'boostfunctionsmult'
=>
'funcC(arg5,arg6)^4.3 funcD(arg7,arg8)^3.4'
,
'userfields'
=>
'date *_ul'
,
);
$this
->
_eDisMax
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'queryparser'
],
$this
->
_eDisMax
->
getQueryParser
());
$this
->
assertEquals
(
$options
[
'queryalternative'
],
$this
->
_eDisMax
->
getQueryAlternative
());
$this
->
assertEquals
(
$options
[
'queryfields'
],
$this
->
_eDisMax
->
getQueryFields
());
$this
->
assertEquals
(
$options
[
'minimummatch'
],
$this
->
_eDisMax
->
getMinimumMatch
());
$this
->
assertEquals
(
$options
[
'phrasefields'
],
$this
->
_eDisMax
->
getPhraseFields
());
$this
->
assertEquals
(
$options
[
'phraseslop'
],
$this
->
_eDisMax
->
getPhraseSlop
());
$this
->
assertEquals
(
$options
[
'phrasebigramfields'
],
$this
->
_eDisMax
->
getPhraseBigramFields
());
$this
->
assertEquals
(
$options
[
'phrasebigramslop'
],
$this
->
_eDisMax
->
getPhraseBigramSlop
());
$this
->
assertEquals
(
$options
[
'phrasetrigramfields'
],
$this
->
_eDisMax
->
getPhraseTrigramFields
());
$this
->
assertEquals
(
$options
[
'phrasetrigramslop'
],
$this
->
_eDisMax
->
getPhraseTrigramSlop
());
$this
->
assertEquals
(
$options
[
'queryphraseslop'
],
$this
->
_eDisMax
->
getQueryPhraseSlop
());
$this
->
assertEquals
(
$options
[
'tie'
],
$this
->
_eDisMax
->
getTie
());
$this
->
assertEquals
(
$options
[
'boostquery'
],
$this
->
_eDisMax
->
getBoostQuery
());
$this
->
assertEquals
(
$options
[
'boostfunctionsmult'
],
$this
->
_eDisMax
->
getBoostFunctionsMult
());
$this
->
assertEquals
(
$options
[
'userfields'
],
$this
->
_eDisMax
->
getUserFields
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
Solarium_Query_Select
::
COMPONENT_EDISMAX
,
$this
->
_eDisMax
->
getType
()
);
}
public
function
testSetAndGetQueryParser
()
{
$value
=
'dummyparser'
;
$this
->
_eDisMax
->
setQueryParser
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getQueryParser
()
);
}
public
function
testSetAndGetQueryAlternative
()
{
$value
=
'*:*'
;
$this
->
_eDisMax
->
setQueryAlternative
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getQueryAlternative
()
);
}
public
function
testSetAndGetQueryFields
()
{
$value
=
'title^2.0 description'
;
$this
->
_eDisMax
->
setQueryFields
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getQueryFields
()
);
}
public
function
testSetAndGetMinimumMatch
()
{
$value
=
'2.0'
;
$this
->
_eDisMax
->
setMinimumMatch
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getMinimumMatch
()
);
}
public
function
testSetAndGetPhraseFields
()
{
$value
=
'title^2.0 description^3.5'
;
$this
->
_eDisMax
->
setPhraseFields
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getPhraseFields
()
);
}
public
function
testSetAndGetPhraseSlop
()
{
$value
=
'2'
;
$this
->
_eDisMax
->
setPhraseSlop
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getPhraseSlop
()
);
}
public
function
testSetAndGetPhraseBigramFields
()
{
$value
=
'description^1.3 date^4.3 field_text2^1.3'
;
$this
->
_eDisMax
->
setPhraseBigramFields
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getPhraseBigramFields
()
);
}
public
function
testSetAndGetPhraseBigramSlop
()
{
$value
=
3
;
$this
->
_eDisMax
->
setPhraseBigramSlop
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getPhraseBigramSlop
()
);
}
public
function
testSetAndGetPhraseTrigramFields
()
{
$value
=
'datetime^4 field1^5 myotherfield^9'
;
$this
->
_eDisMax
->
setPhraseTrigramFields
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getPhraseTrigramFields
()
);
}
public
function
testSetAndGetPhraseTrigramSlop
()
{
$value
=
5
;
$this
->
_eDisMax
->
setPhraseTrigramSlop
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getPhraseTrigramSlop
()
);
}
public
function
testSetAndGetQueryPhraseSlop
()
{
$value
=
'3'
;
$this
->
_eDisMax
->
setQueryPhraseSlop
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getQueryPhraseSlop
()
);
}
public
function
testSetAndGetTie
()
{
$value
=
2.1
;
$this
->
_eDisMax
->
setTie
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getTie
()
);
}
public
function
testSetAndGetBoostQuery
()
{
$value
=
'cat:1^3'
;
$this
->
_eDisMax
->
setBoostQuery
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getBoostQuery
()
);
}
public
function
testSetAndGetBoostFunctions
()
{
$value
=
'funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2'
;
$this
->
_eDisMax
->
setBoostFunctions
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getBoostFunctions
()
);
}
public
function
testSetAndGetBoostFunctionsMult
()
{
$value
=
'funcC(arg5,arg6)^4.3 funcD(arg7,arg8)^3.4'
;
$this
->
_eDisMax
->
setBoostFunctionsMult
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getBoostFunctionsMult
()
);
}
public
function
testSetAndGetUserFields
()
{
$value
=
'date *_ul'
;
$this
->
_eDisMax
->
setUserFields
(
$value
);
$this
->
assertEquals
(
$value
,
$this
->
_eDisMax
->
getUserFields
()
);
}
}
tests/Solarium/Tests/Query/Select/RequestBuilder/Component/FacetSetTest.php
View file @
62b3fbd3
...
@@ -135,6 +135,7 @@ class FacetSetTest extends \PHPUnit_Framework_TestCase
...
@@ -135,6 +135,7 @@ class FacetSetTest extends \PHPUnit_Framework_TestCase
$request
=
$this
->
builder
->
buildComponent
(
$this
->
component
,
$this
->
request
);
$request
=
$this
->
builder
->
buildComponent
(
$this
->
component
,
$this
->
request
);
$this
->
assertEquals
(
$this
->
assertEquals
(
null
,
null
,
$request
->
getRawData
()
$request
->
getRawData
()
...
...
tests/Solarium/Tests/Query/Select/RequestBuilder/RequestBuilderTest.php
View file @
62b3fbd3
...
@@ -158,6 +158,17 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
...
@@ -158,6 +158,17 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
);
);
}
}
public
function
testWithEdismaxComponent
()
{
$this
->
_query
->
getEDisMax
();
$request
=
$this
->
_builder
->
build
(
$this
->
_query
);
$this
->
assertEquals
(
'edismax'
,
$request
->
getParam
(
'defType'
)
);
}
}
}
class
TestDummyComponent
extends
Component
{
class
TestDummyComponent
extends
Component
{
...
...
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