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
4c35b3ac
Commit
4c35b3ac
authored
Jan 13, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new suggester querytype including an example
parent
c48ca8c2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
746 additions
and
1 deletion
+746
-1
examples/2.6-suggester-query.php
examples/2.6-suggester-query.php
+39
-0
examples/index.html
examples/index.html
+2
-0
library/Solarium/Client.php
library/Solarium/Client.php
+35
-0
library/Solarium/Client/RequestBuilder/Suggester.php
library/Solarium/Client/RequestBuilder/Suggester.php
+67
-0
library/Solarium/Client/ResponseParser/Suggester.php
library/Solarium/Client/ResponseParser/Suggester.php
+98
-0
library/Solarium/Query/Suggester.php
library/Solarium/Query/Suggester.php
+185
-0
library/Solarium/Query/Terms.php
library/Solarium/Query/Terms.php
+1
-1
library/Solarium/Result/Suggester.php
library/Solarium/Result/Suggester.php
+173
-0
library/Solarium/Result/Suggester/Term.php
library/Solarium/Result/Suggester/Term.php
+146
-0
No files found.
examples/2.6-suggester-query.php
0 → 100644
View file @
4c35b3ac
<?php
require
(
'init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get a suggester query instance
$query
=
$client
->
createSuggester
();
$query
->
setQuery
(
'ap ip v'
);
//multiple terms
$query
->
setDictionary
(
'suggest'
);
$query
->
setOnlyMorePopular
(
true
);
$query
->
setCount
(
10
);
$query
->
setCollate
(
true
);
// this executes the query and returns the result
$resultset
=
$client
->
suggester
(
$query
);
echo
'<b>Query:</b> '
.
$query
->
getQuery
()
.
'<hr/>'
;
// display results for each term
foreach
(
$resultset
as
$term
=>
$termResult
)
{
echo
'<h3>'
.
$term
.
'</h3>'
;
echo
'NumFound: '
.
$termResult
->
getNumFound
()
.
'<br/>'
;
echo
'StartOffset: '
.
$termResult
->
getStartOffset
()
.
'<br/>'
;
echo
'EndOffset: '
.
$termResult
->
getEndOffset
()
.
'<br/>'
;
echo
'Suggestions:<br/>'
;
foreach
(
$termResult
as
$result
){
echo
'- '
.
$result
.
'<br/>'
;
}
echo
'<hr/>'
;
}
// display collation
echo
'Collation: '
.
$resultset
->
getCollation
();
htmlFooter
();
\ No newline at end of file
examples/index.html
View file @
4c35b3ac
...
@@ -83,6 +83,8 @@
...
@@ -83,6 +83,8 @@
</ul>
</ul>
<li><a
href=
"2.5-terms-query.php"
>
2.5 Terms query
</a></li>
<li><a
href=
"2.5-terms-query.php"
>
2.5 Terms query
</a></li>
<li><a
href=
"2.6-suggester-query.php"
>
2.6 Suggester query
</a></li>
</ul>
</ul>
<li>
4. Usage modes
</li>
<li>
4. Usage modes
</li>
...
...
library/Solarium/Client.php
View file @
4c35b3ac
...
@@ -92,6 +92,11 @@ class Solarium_Client extends Solarium_Configurable
...
@@ -92,6 +92,11 @@ class Solarium_Client extends Solarium_Configurable
*/
*/
const
QUERYTYPE_TERMS
=
'terms'
;
const
QUERYTYPE_TERMS
=
'terms'
;
/**
* Querytype suggester
*/
const
QUERYTYPE_SUGGESTER
=
'suggester'
;
/**
/**
* Default options
* Default options
*
*
...
@@ -142,6 +147,11 @@ class Solarium_Client extends Solarium_Configurable
...
@@ -142,6 +147,11 @@ class Solarium_Client extends Solarium_Configurable
'requestbuilder'
=>
'Solarium_Client_RequestBuilder_Terms'
,
'requestbuilder'
=>
'Solarium_Client_RequestBuilder_Terms'
,
'responseparser'
=>
'Solarium_Client_ResponseParser_Terms'
'responseparser'
=>
'Solarium_Client_ResponseParser_Terms'
),
),
self
::
QUERYTYPE_SUGGESTER
=>
array
(
'query'
=>
'Solarium_Query_Suggester'
,
'requestbuilder'
=>
'Solarium_Client_RequestBuilder_Suggester'
,
'responseparser'
=>
'Solarium_Client_ResponseParser_Suggester'
),
);
);
/**
/**
...
@@ -691,6 +701,20 @@ class Solarium_Client extends Solarium_Configurable
...
@@ -691,6 +701,20 @@ class Solarium_Client extends Solarium_Configurable
return
$this
->
execute
(
$query
);
return
$this
->
execute
(
$query
);
}
}
/**
* Execute a suggester query
*
* @internal This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param Solarium_Query_Suggester $query
* @return Solarium_Result_Suggester
*/
public
function
suggester
(
$query
)
{
return
$this
->
execute
(
$query
);
}
/**
/**
* Create a query instance
* Create a query instance
*
*
...
@@ -793,4 +817,15 @@ class Solarium_Client extends Solarium_Configurable
...
@@ -793,4 +817,15 @@ class Solarium_Client extends Solarium_Configurable
{
{
return
$this
->
createQuery
(
self
::
QUERYTYPE_TERMS
,
$options
);
return
$this
->
createQuery
(
self
::
QUERYTYPE_TERMS
,
$options
);
}
}
/**
* Create a suggester query instance
*
* @param mixed $options
* @return Solarium_Query_Suggester
*/
public
function
createSuggester
(
$options
=
null
)
{
return
$this
->
createQuery
(
self
::
QUERYTYPE_SUGGESTER
,
$options
);
}
}
}
library/Solarium/Client/RequestBuilder/Suggester.php
0 → 100644
View file @
4c35b3ac
<?php
/**
* Copyright 2011 Bas de Nooijer. 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 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
*/
/**
* Build a Suggester query request
*
* @package Solarium
* @subpackage Client
*/
class
Solarium_Client_RequestBuilder_Suggester
extends
Solarium_Client_RequestBuilder
{
/**
* Build request for a Suggester query
*
* @param Solarium_Query_Suggester $query
* @return Solarium_Client_Request
*/
public
function
build
(
$query
)
{
$request
=
parent
::
build
(
$query
);
$request
->
addParam
(
'spellcheck'
,
'true'
);
$request
->
addParam
(
'q'
,
$query
->
getQuery
());
$request
->
addParam
(
'spellcheck.dictionary'
,
$query
->
getDictionary
());
$request
->
addParam
(
'spellcheck.count'
,
$query
->
getCount
());
$request
->
addParam
(
'spellcheck.onlyMorePopular'
,
$query
->
getOnlyMorePopular
());
$request
->
addParam
(
'spellcheck.collate'
,
$query
->
getCollate
());
return
$request
;
}
}
library/Solarium/Client/ResponseParser/Suggester.php
0 → 100644
View file @
4c35b3ac
<?php
/**
* Copyright 2011 Gasol Wu. PIXNET Digital Media Corporation.
* 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 2011 Gasol Wu <gasol.wu@gmail.com>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
*/
/**
* Parse Suggester response data
*
* @package Solarium
* @subpackage Client
*/
class
Solarium_Client_ResponseParser_Suggester
extends
Solarium_Client_ResponseParser
{
/**
* Get result data for the response
*
* @param Solarium_Result_Terms $result
* @return array
*/
public
function
parse
(
$result
)
{
$data
=
$result
->
getData
();
$query
=
$result
->
getQuery
();
$status
=
null
;
$queryTime
=
null
;
if
(
isset
(
$data
[
'responseHeader'
]))
{
$status
=
$data
[
'responseHeader'
][
'status'
];
$queryTime
=
$data
[
'responseHeader'
][
'QTime'
];
}
$suggestions
=
array
();
$collation
=
null
;
if
(
isset
(
$data
[
'spellcheck'
][
'suggestions'
])
&&
is_array
(
$data
[
'spellcheck'
][
'suggestions'
]))
{
$suggestResults
=
$data
[
'spellcheck'
][
'suggestions'
];
$termClass
=
$query
->
getOption
(
'termclass'
);
for
(
$i
=
0
;
$i
<
count
(
$suggestResults
);
$i
+=
2
)
{
$term
=
$suggestResults
[
$i
];
$termData
=
$suggestResults
[
$i
+
1
];
if
(
$term
==
'collation'
&&
$i
==
count
(
$suggestResults
)
-
2
)
{
$collation
=
$termData
;
}
else
{
$suggestions
[
$term
]
=
new
$termClass
(
$termData
[
'numFound'
],
$termData
[
'startOffset'
],
$termData
[
'endOffset'
],
$termData
[
'suggestion'
]
);
}
}
}
return
array
(
'status'
=>
$status
,
'queryTime'
=>
$queryTime
,
'results'
=>
$suggestions
,
'collation'
=>
$collation
,
);
}
}
library/Solarium/Query/Suggester.php
0 → 100644
View file @
4c35b3ac
<?php
/**
* Copyright 2011 Bas de Nooijer. 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 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
*/
/**
* Suggester Query
*
* Can be used for an autocomplete feature. See http://wiki.apache.org/solr/Suggester for more info.
*
* @package Solarium
* @subpackage Query
*/
class
Solarium_Query_Suggester
extends
Solarium_Query
{
/**
* Get type for this query
*
* @return string
*/
public
function
getType
()
{
return
Solarium_Client
::
QUERYTYPE_SUGGESTER
;
}
/**
* Default options
*
* @var array
*/
protected
$_options
=
array
(
'handler'
=>
'suggest'
,
'resultclass'
=>
'Solarium_Result_Suggester'
,
'termclass'
=>
'Solarium_Result_Suggester_Term'
,
);
/**
* Set query option
*
* Query to spellcheck
*
* @param string $query
* @return self Provides fluent interface
*/
public
function
setQuery
(
$query
)
{
return
$this
->
_setOption
(
'query'
,
$query
);
}
/**
* Get query option
*
* @return string|null
*/
public
function
getQuery
()
{
return
$this
->
getOption
(
'query'
);
}
/**
* Set dictionary option
*
* The name of the dictionary to use
*
* @param string $dictionary
* @return self Provides fluent interface
*/
public
function
setDictionary
(
$dictionary
)
{
return
$this
->
_setOption
(
'dictionary'
,
$dictionary
);
}
/**
* Get dictionary option
*
* @return string|null
*/
public
function
getDictionary
()
{
return
$this
->
getOption
(
'dictionary'
);
}
/**
* Set count option
*
* The maximum number of suggestions to return
*
* @param int $count
* @return self Provides fluent interface
*/
public
function
setCount
(
$count
)
{
return
$this
->
_setOption
(
'count'
,
$count
);
}
/**
* Get count option
*
* @return int|null
*/
public
function
getCount
()
{
return
$this
->
getOption
(
'count'
);
}
/**
* Set onlyMorePopular option
*
* Only return suggestions that result in more hits for the query than the existing query
*
* @param boolean $onlyMorePopular
* @return self Provides fluent interface
*/
public
function
setOnlyMorePopular
(
$onlyMorePopular
)
{
return
$this
->
_setOption
(
'onlymorepopular'
,
$onlyMorePopular
);
}
/**
* Get onlyMorePopular option
*
* @return boolean|null
*/
public
function
getOnlyMorePopular
()
{
return
$this
->
getOption
(
'onlymorepopular'
);
}
/**
* Set collate option
*
* @param boolean $collate
* @return self Provides fluent interface
*/
public
function
setCollate
(
$collate
)
{
return
$this
->
_setOption
(
'collate'
,
$collate
);
}
/**
* Get collate option
*
* @return boolean|null
*/
public
function
getCollate
()
{
return
$this
->
getOption
(
'collate'
);
}
}
library/Solarium/Query/Terms.php
View file @
4c35b3ac
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
*/
*/
/**
/**
* Ter
n
s query
* Ter
m
s query
*
*
* A terms query provides access to the indexed terms in a field and the number of documents that match each term.
* A terms query provides access to the indexed terms in a field and the number of documents that match each term.
* This can be useful for doing auto-suggest or other things that operate at the term level instead of the search
* This can be useful for doing auto-suggest or other things that operate at the term level instead of the search
...
...
library/Solarium/Result/Suggester.php
0 → 100644
View file @
4c35b3ac
<?php
/**
* Copyright 2011 Bas de Nooijer. 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 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Suggester query result
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Suggester
extends
Solarium_Result_QueryType
implements
IteratorAggregate
,
Countable
{
/**
* Status code returned by Solr
*
* @var int
*/
protected
$_status
;
/**
* Solr index queryTime
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @var int
*/
protected
$_queryTime
;
/**
* Suggester results
*
* @var array
*/
protected
$_results
;
/**
* Collation result
*
* Only available when collate is enabled in the suggester query
*
* @var string
*/
protected
$_collation
;
/**
* Get Solr status code
*
* This is not the HTTP status code! The normal value for success is 0.
*
* @return int
*/
public
function
getStatus
()
{
$this
->
_parseResponse
();
return
$this
->
_status
;
}
/**
* Get Solr query time
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @return int
*/
public
function
getQueryTime
()
{
$this
->
_parseResponse
();
return
$this
->
_queryTime
;
}
/**
* Get all results
*
* @return array
*/
public
function
getResults
()
{
$this
->
_parseResponse
();
return
$this
->
_results
;
}
/**
* Get results for a specific term
*
* @param string $field
* @return array
*/
public
function
getTerm
(
$term
)
{
$this
->
_parseResponse
();
if
(
isset
(
$this
->
_results
[
$term
]))
{
return
$this
->
_results
[
$term
];
}
else
{
return
array
();
}
}
/**
* IteratorAggregate implementation
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
$this
->
_parseResponse
();
return
new
ArrayIterator
(
$this
->
_results
);
}
/**
* Countable implementation
*
* @return int
*/
public
function
count
()
{
$this
->
_parseResponse
();
return
count
(
$this
->
_results
);
}
/**
* Get collation
*
* @return null|string
*/
public
function
getCollation
()
{
$this
->
_parseResponse
();
return
$this
->
_collation
;
}
}
\ No newline at end of file
library/Solarium/Result/Suggester/Term.php
0 → 100644
View file @
4c35b3ac
<?php
/**
* Copyright 2011 Bas de Nooijer. 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 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Suggester query term result
*
* @package Solarium
* @subpackage Result
*/
class
Solarium_Result_Suggester_term
implements
IteratorAggregate
,
Countable
{
/**
* @var int
*/
protected
$_numFound
;
/**
* @var int
*/
protected
$_startOffset
;
/**
* @var int
*/
protected
$_endOffset
;
/**
* @var array
*/
protected
$_suggestions
;
/**
* Constructor
*
* @param int $numFound
* @param int $startOffset
* @param int $endOffset
* @param array $suggestions
*/
public
function
__construct
(
$numFound
,
$startOffset
,
$endOffset
,
$suggestions
)
{
$this
->
_numFound
=
$numFound
;
$this
->
_startOffset
=
$startOffset
;
$this
->
_endOffset
=
$endOffset
;
$this
->
_suggestions
=
$suggestions
;
}
/**
* Get NumFound
*
* @return int
*/
public
function
getNumFound
()
{
return
$this
->
_numFound
;
}
/**
* Get StartOffset
*
* @return int
*/
public
function
getStartOffset
()
{
return
$this
->
_startOffset
;
}
/**
* Get EndOffset
*
* @return int
*/
public
function
getEndOffset
()
{
return
$this
->
_endOffset
;
}
/**
* Get suggestions
*
* @return array
*/
public
function
getSuggestions
()
{
return
$this
->
_suggestions
;
}
/**
* IteratorAggregate implementation
*
* @return ArrayIterator
*/
public
function
getIterator
()
{
return
new
ArrayIterator
(
$this
->
_suggestions
);
}
/**
* Countable implementation
*
* @return int
*/
public
function
count
()
{
return
count
(
$this
->
_suggestions
);
}
}
\ No newline at end of file
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