PHP Doku:: Enables or disables moreLikeThis - solrquery.setmlt.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSuchmaschinenerweiterungenApache SolrThe SolrQuery classSolrQuery::setMlt

Ein Service von Reinhard Neidl - Webprogrammierung.

The SolrQuery class

<<SolrQuery::setHighlightUsePhraseHighlighter

SolrQuery::setMltBoost>>

SolrQuery::setMlt

(PECL solr >= 0.9.2)

SolrQuery::setMltEnables or disables moreLikeThis

Beschreibung

publicSolrQuery SolrQuery::setMlt ( bool $flag )

Enables or disables moreLikeThis

Parameter-Liste

flag

TRUE enables it and FALSE turns it off.

Rückgabewerte

Returns the current SolrQuery object, if the return value is used.


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
duerra at nospam dot yahoo dot com
19.11.2010 1:34
Note that currently, if enabling MLT results in Solr, you also need to set the MinDocFrequency and MinTermFrequency, or you will not get any results back.

<?php
$client
= new SolrClient($params);
$query = new SolrQuery();
$query->setMlt(true);
$query->addField('*,score');
$query->setMltMinDocFrequency(1);
$query->setMltMinTermFrequency(1);

//What the MLT documents will be based off of
$query->setQuery('id:doc_10');
$result = $client->query($query);
$result->setParseMode(SolrQueryResponse::PARSE_SOLR_OBJ);
$response = $result->getResponse();

//MLT returns an array of documents based off of the id field value of EACH result returned in the primary search, with an array of MLT documents for each main result document returned

//Presuming the unique field in our schema above is "id" and I know that I will only be getting one document returned in the primary result set, then:
$similarDocs = $response->moreLikeThis->doc_10->docs;

?>

Hope this helps.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)