Solr
From Cyclone3 Wiki
(Difference between revisions)
(→Examples) |
(→Examples) |
||
Line 56: | Line 56: | ||
} | } | ||
); | ); | ||
+ | |||
+ | == Geo-location or spatial search == | ||
+ | |||
+ | http://wiki.apache.org/solr/SpatialSearch |
Current revision
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", } );