search/plugins/ezsolr/ezsolr.php
function moreLikeThis( $queryType, $queryValue, $params = array() )
    {
        eZDebug::createAccumulator( 'MoreLikeThis', 'eZ Find' );
        eZDebug::accumulatorStart( 'MoreLikeThis' );
        $error = 'Server not running';

        $asObjects = isset( $params['AsObjects'] ) ? $params['AsObjects'] : true;

        //mlt does not support distributed search yet, so find out which is
        //the language core to use and qyery only this one
        //search across languages does not make sense here
        $coreToUse = null;
        if ( $this->UseMultiLanguageCores == true )
        {
            $languages = $this->SiteINI->variable( 'RegionalSettings', 'SiteLanguageList' );
            if ( array_key_exists ( $languages[0], $this->SolrLanguageShards ) )
            {
                $coreToUse = $this->SolrLanguageShards[$languages[0]];
            }
        }
        else
        {
            $coreToUse = $this->Solr;
        }

        if ( trim( $queryType ) == '' || trim( $queryValue ) == '' )
        {
            $error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $queryType . ', Query Value = ' . $queryValue;
            eZDebug::writeNotice( $error, __METHOD__ );
            $resultArray = null;
        }
        else
        {
            eZDebug::createAccumulator( 'Query build', 'eZ Find' );
            eZDebug::accumulatorStart( 'Query build' );
            $queryBuilder = new ezfeZPSolrQueryBuilder( $this );
            $queryParams = $queryBuilder->buildMoreLikeThis( $queryType, $queryValue, $params );
            eZDebug::accumulatorStop( 'Query build' );

            eZDebug::createAccumulator( 'Engine time', 'eZ Find' );
            eZDebug::accumulatorStart( 'Engine time' );
            $resultArray = $coreToUse->rawSolrRequest( '/mlt', $queryParams );
            eZDebug::accumulatorStop( 'Engine time' );
        }

        if ( $resultArray )
        {
            $searchCount = $resultArray[ 'response' ][ 'numFound' ];
            $objectRes = $this->buildResultObjects(
                $resultArray, $searchCount, $asObjects, $params
            );

            $stopWordArray = array();

            eZDebugSetting::writeDebug( 'extension-ezfind-query-mlt', $resultArray['interestingTerms'], 'MoreLikeThis terms' );
            return array(
                'SearchResult' => $objectRes,
                'SearchCount' => $searchCount,
                'StopWordArray' => $stopWordArray,
                'SearchExtras' => new ezfSearchResultInfo( $resultArray )
            );
        }
        else
        {
            return array(
                'SearchResult' => false,
                'SearchCount' => 0,
                'StopWordArray' => array(),
                'SearchExtras' => new ezfSearchResultInfo( array( 'error' => ezpI18n::tr( 'ezfind', $error ) ) ) );
        }
    }
function moreLikeThis( $queryType, $queryValue, $params = array() )
    {
        eZDebug::createAccumulator( 'MoreLikeThis', 'eZ Find' );
        eZDebug::accumulatorStart( 'MoreLikeThis' );
        $error = 'Server not running';

        $asObjects = isset( $params['AsObjects'] ) ? $params['AsObjects'] : true;

        //mlt does not support distributed search yet, so find out which is
        //the language core to use and qyery only this one
        //search across languages does not make sense here
        $coreToUse = null;
        if ( $this->UseMultiLanguageCores == true )
        {
            $languages = $this->SiteINI->variable( 'RegionalSettings', 'SiteLanguageList' );
            if ( array_key_exists ( $languages[0], $this->SolrLanguageShards ) )
            {
                $coreToUse = $this->SolrLanguageShards[$languages[0]];
            }
        }
        else
        {
            $coreToUse = $this->Solr;
        }

        if ( trim( $queryType ) == '' || trim( $queryValue ) == '' )
        {
            $error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $queryType . ', Query Value = ' . $queryValue;
            eZDebug::writeNotice( $error, __METHOD__ );
            $resultArray = null;
        }
        else
        {
            eZDebug::createAccumulator( 'Query build', 'eZ Find' );
            eZDebug::accumulatorStart( 'Query build' );
            $queryBuilder = new ezfeZPSolrQueryBuilder( $this );
            $queryParams = $queryBuilder->buildMoreLikeThis( $queryType, $queryValue, $params );
            eZDebug::accumulatorStop( 'Query build' );

            eZDebug::createAccumulator( 'Engine time', 'eZ Find' );
            eZDebug::accumulatorStart( 'Engine time' );
            $resultArray = $coreToUse->rawSolrRequest( '/mlt', $queryParams );
            eZDebug::accumulatorStop( 'Engine time' );
        }

        if ( $resultArray )
        {
            $searchCount = $resultArray[ 'response' ][ 'numFound' ];
            $objectRes = $this->buildResultObjects(
                $resultArray, $searchCount, $asObjects, $params
            );

            $stopWordArray = array();

            eZDebugSetting::writeDebug( 'extension-ezfind-query-mlt', $resultArray['interestingTerms'], 'MoreLikeThis terms' );
            return array(
                'SearchResult' => $objectRes,
                'SearchCount' => $searchCount,
                'StopWordArray' => $stopWordArray,
                'SearchExtras' => new ezfSearchResultInfo( $resultArray )
            );
        }
        else
        {
            return array(
                'SearchResult' => false,
                'SearchCount' => 0,
                'StopWordArray' => array(),
                'SearchExtras' => new ezfSearchResultInfo( array( 'error' => ezpI18n::tr( 'ezfind', $error ) ) ) );
        }
    }
function moreLikeThis ( $ queryType , $ queryValue , $ params = array ( ) ) { eZDebug :: createAccumulator ( 'MoreLikeThis' , 'eZ Find' ) ; eZDebug :: accumulatorStart ( 'MoreLikeThis' ) ; $ error = 'Server not running' ; $ asObjects = isset ( $ params [ 'AsObjects' ] ) ? $ params [ 'AsObjects' ] : true ; //mlt does not support distributed search yet, so find out which is //the language core to use and qyery only this one //search across languages does not make sense here $ coreToUse = null ; if ( $ this -> UseMultiLanguageCores == true ) { $ languages = $ this -> SiteINI -> variable ( 'RegionalSettings' , 'SiteLanguageList' ) ; if ( array_key_exists ( $ languages [ 0 ] , $ this -> SolrLanguageShards ) ) { $ coreToUse = $ this -> SolrLanguageShards [ $ languages [ 0 ] ] ; } } else { $ coreToUse = $ this -> Solr ; } if ( trim ( $ queryType ) == '' || trim ( $ queryValue ) == '' ) { $ error = 'Missing query arguments for More Like This: ' . 'querytype = ' . $ queryType . ', Query Value = ' . $ queryValue ; eZDebug :: writeNotice ( $ error , __METHOD__ ) ; $ resultArray = null ; } else { eZDebug :: createAccumulator ( 'Query build' , 'eZ Find' ) ; eZDebug :: accumulatorStart ( 'Query build' ) ; $ queryBuilder = new ezfeZPSolrQueryBuilder ( $ this ) ; $ queryParams = $ queryBuilder -> buildMoreLikeThis ( $ queryType , $ queryValue , $ params ) ; eZDebug :: accumulatorStop ( 'Query build' ) ; eZDebug :: createAccumulator ( 'Engine time' , 'eZ Find' ) ; eZDebug :: accumulatorStart ( 'Engine time' ) ; $ resultArray = $ coreToUse -> rawSolrRequest ( '/mlt' , $ queryParams ) ; eZDebug :: accumulatorStop ( 'Engine time' ) ; } if ( $ resultArray ) { $ searchCount = $ resultArray [ 'response' ] [ 'numFound' ] ; $ objectRes = $ this -> buildResultObjects ( $ resultArray , $ searchCount , $ asObjects , $ params ) ; $ stopWordArray = array ( ) ; eZDebugSetting :: writeDebug ( 'extension-ezfind-query-mlt' , $ resultArray [ 'interestingTerms' ] , 'MoreLikeThis terms' ) ; return array ( 'SearchResult' => $ objectRes , 'SearchCount' => $ searchCount , 'StopWordArray' => $ stopWordArray , 'SearchExtras' => new ezfSearchResultInfo ( $ resultArray ) ) ; } else { return array ( 'SearchResult' => false , 'SearchCount' => 0 , 'StopWordArray' => array ( ) , 'SearchExtras' => new ezfSearchResultInfo ( array ( 'error' => ezpI18n :: tr ( 'ezfind' , $ error ) ) ) ) ; } }
More like this is pretty similar to normal search, but usually only the object or node id are sent to Solr
However, streams or a search text body can also be passed .. Solr will extract the important terms and build a
query for us

@param string $queryType is one of 'noid', 'oid', 'url', 'text'
@param $queryValue the node id, object id, url or text body to use
@param array parameters. @see ezfeZPSolrQueryBuilder::buildMoreLikeThis()

@return array List of eZFindResultNode objects.

@todo: add functionality not to call the DB to recreate objects : $asObjects == false
More like this is pretty similar to normal search but usually only the object or node id are sent to Solr However streams or a search text body can also be passed .. Solr will extract the important terms and build a query for us