Commit e0845dcc authored by Bas de Nooijer's avatar Bas de Nooijer

- reorganized example numbering

- added new examples for MLT and peclhttp
parent 22213ac7
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a morelikethis query instance
$query = $client->createMoreLikeThis();
$query->setQuery('id:SP2514N');
$query->setMltFields('manu,cat');
$query->setMinimumDocumentFrequency(1);
$query->setMinimumTermFrequency(1);
$query->createFilterQuery('stock')->setQuery('inStock:true');
$query->setInterestingTerms('details');
$query->setMatchInclude(true);
// this executes the query and returns the result
$resultset = $client->select($query);
echo 'Document used for matching:<br/><table>';
foreach($resultset->getMatch() 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><hr/>';
// display the total number of MLT documents found by solr
echo 'Number of MLT matches found: '.$resultset->getNumFound().'<br/><br/>';
echo '<b>Listing of matched docs:</b>';
// show MLT 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
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a morelikethis query instance
$query = $client->createMoreLikeThis();
$query->setQuery('electronics memory');
$query->setQueryStream(true);
$query->setMltFields('manu,cat');
$query->setMinimumDocumentFrequency(1);
$query->setMinimumTermFrequency(1);
$query->createFilterQuery('stock')->setQuery('inStock:true');
$query->setInterestingTerms('details');
$query->setMatchInclude(true);
// this executes the query and returns the result
$resultset = $client->select($query);
echo 'Document used for matching:<br/><table>';
foreach($resultset->getMatch() 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><hr/>';
// display the total number of MLT documents found by solr
echo 'Number of MLT matches found: '.$resultset->getNumFound().'<br/><br/>';
echo '<b>Listing of matched docs:</b>';
// show MLT 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
<?php
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// set the adapter to peclhttp
$client->setAdapter('Solarium_Client_Adapter_PeclHttp');
// get a select query instance
$query = $client->createSelect();
// 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
...@@ -26,38 +26,47 @@ ...@@ -26,38 +26,47 @@
<li><a href="1.3-basic-update.php">1.3 Basic update - add document</a></li> <li><a href="1.3-basic-update.php">1.3 Basic update - add document</a></li>
</ul> </ul>
<li>2. Select query</li> <li>2. Queries</li>
<ul style="list-style:none;"> <ul style="list-style:none;">
<li><a href="2.1-query-params.php">2.1 Select query params</a></li> <li>2.1. Select query</li>
<li><a href="2.2-custom-result-document.php">2.2 Custom result document</a></li>
<li><a href="2.3-filterquery.php">2.3 Filterquery</a></li>
<li>2.4 Components</li>
<ul style="list-style:none;"> <ul style="list-style:none;">
<li>2.5.1 FacetSet</li> <li><a href="2.1.1-query-params.php">2.1.1 Select query params</a></li>
<li><a href="2.1.2-custom-result-document.php">2.1.2 Custom result document</a></li>
<li><a href="2.1.3-filterquery.php">2.1.3 Filterquery</a></li>
<li>2.1.4 Components</li>
<ul style="list-style:none;"> <ul style="list-style:none;">
<li><a href="2.5.1.1-facet-field.php">2.5.1.1 Facet field</a></li> <li>2.1.5.1 FacetSet</li>
<li><a href="2.5.1.2-facet-query.php">2.5.1.2 Facet query</a></li> <ul style="list-style:none;">
<li><a href="2.5.1.3-facet-multiquery.php">2.5.1.3 Facet multiquery</a></li> <li><a href="2.1.5.1.1-facet-field.php">2.1.5.1.1 Facet field</a></li>
<li><a href="2.5.1.4-facet-range.php">2.5.1.4 Facet range</a></li> <li><a href="2.1.5.1.2-facet-query.php">2.1.5.1.2 Facet query</a></li>
<li><a href="2.1.5.1.3-facet-multiquery.php">2.1.5.1.3 Facet multiquery</a></li>
<li><a href="2.1.5.1.4-facet-range.php">2.1.5.1.4 Facet range</a></li>
</ul> </ul>
<li><a href="2.5.2-morelikethis.php">2.5.2 MoreLikeThis</a></li> <li><a href="2.1.5.2-morelikethis.php">2.1.5.2 MoreLikeThis</a></li>
<li><a href="2.5.3-highlighting.php">2.5.3 Highlighting</a></li> <li><a href="2.1.5.3-highlighting.php">2.1.5.3 Highlighting</a></li>
<li><a href="2.5.4-dismax.php">2.5.4 Dismax</a></li> <li><a href="2.1.5.4-dismax.php">2.1.5.4 Dismax</a></li>
<li><a href="2.5.5-edismax.php">2.5.5 Edismax</a></li> <li><a href="2.1.5.5-edismax.php">2.1.5.5 Edismax</a></li>
<li><a href="2.5.6-grouping-by-field.php">2.5.5 Grouping by field</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.5.7-grouping-by-query.php">2.5.6 Grouping by query</a></li> <li><a href="2.1.5.7-grouping-by-query.php">2.1.5.6 Grouping by query</a></li>
</ul> </ul>
<li><a href="2.6-helper-functions.php">2.6 Helper functions</a></li> <li><a href="2.1.6-helper-functions.php">2.1.6 Helper functions</a></li>
<li><a href="2.7-query-reuse.php">2.7 Query re-use</a></li> <li><a href="2.1.7-query-reuse.php">2.1.7 Query re-use</a></li>
</ul> </ul>
<li>3. Update query</li> <li>2.2. Update query</li>
<ul style="list-style:none;"> <ul style="list-style:none;">
<li><a href="3.1-add-docs.php">3.1 Add docs</a></li> <li><a href="2.2.1-add-docs.php">2.2.1 Add docs</a></li>
<li><a href="3.2-delete-by-query.php">3.2 Delete by query</a></li> <li><a href="2.2.2-delete-by-query.php">2.2.2 Delete by query</a></li>
<li><a href="3.3-delete-by-id.php">3.3 Delete by ID</a></li> <li><a href="2.2.3-delete-by-id.php">2.2.3 Delete by ID</a></li>
<li><a href="3.4-optimize.php">3.4 Optimize index</a></li> <li><a href="2.2.4-optimize.php">2.2.4 Optimize index</a></li>
<li><a href="3.5-rollback.php">3.5 Rollback</a></li> <li><a href="2.2.5-rollback.php">2.2.5 Rollback</a></li>
</ul>
<li>2.3. MoreLikeThis query</li>
<ul style="list-style:none;">
<li><a href="2.3.1-mlt-query.php">2.3.1 MoreLikeThis query</a></li>
<li><a href="2.3.2-mlt-stream.php">2.3.2 MoreLikeThis query input as stream</a></li>
</ul>
</ul> </ul>
<li>4. Usage modes</li> <li>4. Usage modes</li>
...@@ -80,7 +89,11 @@ ...@@ -80,7 +89,11 @@
<li>6. Miscellaneous</li> <li>6. Miscellaneous</li>
<ul style="list-style:none;"> <ul style="list-style:none;">
<li><a href="6.1-zend-http-adapter.php">6.1 Zend_Http adapter</a></li> <li>6.1 Client adapters</li>
<ul style="list-style:none;">
<li><a href="6.1.1-zend-http-adapter.php">6.1 Zend_Http adapter</a></li>
<li><a href="6.1.2-pecl-http-adapter.php">6.2 Pecl_Http adapter</a></li>
</ul>
<li><a href="6.2-escaping.php">6.2 Escaping</a></li> <li><a href="6.2-escaping.php">6.2 Escaping</a></li>
<li><a href="6.3-placeholder-syntax.php">6.3 Placeholder syntax</a></li> <li><a href="6.3-placeholder-syntax.php">6.3 Placeholder syntax</a></li>
</ul> </ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment