[TYPO3-Solr] Use solr fulltext search as a filter in my extension

Rolf Nakielski rolf at nakielski.de
Tue Jun 23 16:15:58 CEST 2015


OK - it may be a good idea to do all filtering by solr - but for various
reasons this was not suitable for our project.
But we finally integrated a solr full text search in our extension using
the indexing for our table and relations as described for tx_news and do
the search like this in our repository:

        if($filter->getSearchString()){
            $searchString = urlencode(str_replace(' ', '+',
trim($filter->getSearchString())));
            $url = '
http://localhost:8080/mysolr/mycore/select?rows=99999&wt=xml&fq=type:tx_myext_domain_model_something&fl=uid&q='
. $searchString;
            $xmlString = file_get_contents($url);
            $xml = simplexml_load_string($xmlString);
            if($xml){
                $result =
$xml->xpath('/response/result/doc/int[@name="uid"]');
                foreach($result as $uid){
                    $searchUids[] = intval($uid);
                }
            }
        }

The array $searchUids can than be used in the query among the other filters.
Pretty easy to do and works well.

Maybe this helps anybody who needs to do something similar.

rolf


More information about the TYPO3-project-solr mailing list