Cyclone3 Skin

Solr

From Cyclone3 Wiki

(Difference between revisions)
(New page: Apache Solr is document fulltext search engine integrated in Cyclone3 = Enable = Add line with Solr url into TOM.conf $Ext::Solr::url='http://localhost:8080/solr'; = Examples = ...)
(Examples)
Line 9: Line 9:
= Examples =
= 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 ==
== Search in articles and boost score of newer items ==

Revision as of 12:10, 21 April 2012

Apache Solr is document fulltext search engine integrated in Cyclone3

Contents

Enable

Add line with Solr url into TOM.conf

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


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"
   }
);