forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new examples and improved some existing examples for 2.1.0
- Loading branch information
1 parent
daec42c
commit ce1d99f
Showing
6 changed files
with
61 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
require('init.php'); | ||
htmlHeader(); | ||
|
||
// create a client instance | ||
$client = new Solarium_Client($config); | ||
|
||
// get a select query instance | ||
$query = $client->createSelect(); | ||
|
||
// search input string, this value fails without escaping because of the double-quote | ||
$input = 'ATA "133'; | ||
|
||
// the placeholder syntax applies phrase escaping to the first term | ||
// see the manual for all supported formats | ||
$query->setQuery('features: %p1% AND inStock:%2%',array($input,1)); | ||
|
||
// show the result after replacing the placeholders with values | ||
echo $query->getQuery() . '<br/>'; | ||
|
||
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters