I have this script:
$removeList = array('+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\');
$keyword = str_replace($removeList, '', mb_strtolower($_GET['query'], 'UTF-8'));
$keyword_str = strlen($keyword);
if($keyword_str>=3){
$options = array('hostname' => '**.*.*.*','login' => '', 'password' => '', 'port' => 8080);
$client = new SolrClient($options);
$query = new SolrQuery();
$query->setTerms(true);
$query->setTermsLimit(10);
$query->setTermsSort(1);
$query->setTermsField('keywords')->setTermsPrefix($keyword);
$updateResponse = $client->query($query);
}
This script is working fine. But how can I make it search by category?
Example: my var are $_GET['query'] = 'au' but i want to search only in cat = 2. Now its searching the whole DB. how can I make that? thanks.
Do you need to use the TermsComponent? If not, my suggestion would be to build your query by using
SolrQuery::setQueryand setting a static filter on the cat field by the help of Solr’s Query Syntax.Example:
… or in short form using
SolrQueryconstructor: