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
762fd57c
Commit
762fd57c
authored
Sep 27, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added example for distributed search
parent
2ab3d9f1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
examples/2.1.5.8-distributed-search.php
examples/2.1.5.8-distributed-search.php
+41
-0
examples/index.html
examples/index.html
+1
-0
No files found.
examples/2.1.5.8-distributed-search.php
0 → 100644
View file @
762fd57c
<?php
require
(
'init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium_Client
(
$config
);
// get a select query instance
$query
=
$client
->
createSelect
();
// add distributed search settings
// see http://wiki.apache.org/solr/DistributedSearch#Distributed_Search_Example for setting up two solr instances
$distributedSearch
=
$query
->
getDistributedSearch
();
$distributedSearch
->
addShard
(
'shard1'
,
'localhost:8983/solr'
);
$distributedSearch
->
addShard
(
'shard2'
,
'localhost:7574/solr'
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
// display the total number of documents found by solr
echo
'NumFound: '
.
$resultset
->
getNumFound
();
// show documents using the resultset iterator
foreach
(
$resultset
as
$document
)
{
echo
'<hr/><table>'
;
// the documents are also iterable, to get all fields
foreach
(
$document
AS
$field
=>
$value
)
{
// 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>'
;
}
echo
'</table>'
;
}
htmlFooter
();
\ No newline at end of file
examples/index.html
View file @
762fd57c
...
...
@@ -52,6 +52,7 @@
<li><a
href=
"2.1.5.5-edismax.php"
>
2.1.5.5 Edismax
</a></li>
<li><a
href=
"2.1.5.6-grouping-by-field.php"
>
2.1.5.5 Grouping by field
</a></li>
<li><a
href=
"2.1.5.7-grouping-by-query.php"
>
2.1.5.6 Grouping by query
</a></li>
<li><a
href=
"2.1.5.8-distributed-search.php"
>
2.1.5.6 Distributed search (sharding)
</a></li>
</ul>
<li><a
href=
"2.1.6-helper-functions.php"
>
2.1.6 Helper functions
</a></li>
<li><a
href=
"2.1.7-query-reuse.php"
>
2.1.7 Query re-use
</a></li>
...
...
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