# Copyright 2010 by Peter Karman. Licensed under the same terms as Perl. # # similar to opensearch.psgi but using # Search::OpenSearch::Server::Plack for much less code. # # use strict; use warnings; use Carp; use Plack::Request; use Plack::App::URLMap; use Plack::App::File; use Plack::Builder; use Search::OpenSearch; use Search::OpenSearch::Server::Plack; use Data::Dump qw( dump ); # should only need to change this path my $index_ks = '/Users/karpet/projects/search_bench/fpks.index/'; # nothing else my $engine_config = { type => 'KSx', index => [$index_ks], facets => { names => [qw( topics people places orgs author )], sample_size => 10_000, }, fields => [qw( topics people places orgs author )], debug => $ENV{PERL_DEBUG} || 0, }; my $DEFAULT_PAGE = < Demo Search::OpenSearch
EOF { package MyServer; @MyServer::ISA = ('Search::OpenSearch::Server::Plack'); sub handle_no_query { my ( $self, $response ) = @_; $response->status(200); $response->content_type('text/html'); $response->body($DEFAULT_PAGE); return $response; } } my $app = MyServer->new( engine_config => $engine_config ); builder { # necessary for Ext callback to work enable "JSONP"; # serve our static content from same dir as this script mount "/static" => Plack::App::File->new( root => "./" ); mount "/resources/images/default" => Plack::App::File->new( root => "./" ); # serve dynamic content using MyServer mount '/' => $app; };