Cyclone3 Skin

Solr

From Cyclone3 Wiki

(Difference between revisions)
(Enable)
(Examples)
Line 41: Line 41:
'hl.fl' => "title description",
'hl.fl' => "title description",
'hl.fragsize' => "400"
'hl.fragsize' => "400"
 +
}
 +
);
 +
 +
== Boost by attributes ==
 +
 +
my $response = $solr->search(
 +
'*',
 +
{
 +
'rows' => 30,
 +
'defType' => 'edismax',
 +
'bq' => '+id:example_tld.product.* +mnozstvo_f:[1 TO *] ALKOHOL_s:13^0.5',
 +
'qf' => "name score",
 +
'fl' => "id score mnozstvo_f ALKOHOL_s",
}
}
);
);

Revision as of 09:02, 1 May 2012

Apache Solr is document fulltext search engine integrated in Cyclone3

Contents

Configuration

Add line with Solr url into TOM.conf

$Ext::Solr::url='http://localhost:8080/solr';

Copy special Cyclone3 schema.xml to solr configuration From:

${CYCLONE3_PATH}/_addons/Ext/Solr/schema.xml

Examples

Basic use and variables

my $solr = Ext::Solr::service();
my $response = $solr->search(...);
my $score_max=$response->content->{'response'}->{'maxScore'};
my $rows=$response->content->{'response'}->{'numFound'};
for my $doc ( $response->docs )
{
    my $id=$doc->value_for('id');
    my $title=$response->content->{'highlighting'}->{$id}->{'title'}[0]
       || $doc->value_for('title');
}

Search in articles and boost score of newer items

my $boost='recip(ms(NOW/HOUR,last_modified),3.16e-11,1,1)';
my $response = $solr->search(
   "{!boost b=$boost} ".$query,
   {
       'rows' => 10,
       'defType' => 'dismax',
       'mm' => "100%",
       'bq' => '+id:example_tld.a401_article.sk.*',
       'qf' => "title^1.2 description^0.8 keywords^0.5 text^0.2",
       'fl' => "id ID_entity_i title description text score last_modified",
       'hl' => "true" ,
       'hl.fl' => "title description",
       'hl.fragsize' => "400"
   }
);

Boost by attributes

my $response = $solr->search(
   '*',
   {
       'rows' => 30,
       'defType' => 'edismax',
       'bq' => '+id:example_tld.product.* +mnozstvo_f:[1 TO *] ALKOHOL_s:13^0.5',
       'qf' => "name score",
       'fl' => "id score mnozstvo_f ALKOHOL_s",
   }
);