[lucy-user] Lucy client/server

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[lucy-user] Lucy client/server

raja raja
Hi,

I am trying to run Lucy (Lucy-0.6.1 : https://metacpan.org/release/Lucy) in client server mode on Ubuntu as follows:


#server.pl
#!/perl/bin/perl

use strict;
use warnings;
use Lucy::Search::IndexSearcher;
use LucyX::Remote::SearchServer;

my $searcher = Lucy::Search::IndexSearcher->new(
index => 'indexdir'
);
my $search_server = LucyX::Remote::SearchServer->new(
searcher => $searcher
);
$search_server->serve(
port => 7890,
);


#client.pl
#!/perl/bin/perl

use strict;
use warnings;
use Lucy::Search::IndexSearcher;
use LucyX::Remote::SearchClient;

my $client = LucyX::Remote::SearchClient->new(
peer_address => 'localhost:7890',
);

my $hits = $client->hits( query => "nike" );
while ( my $hit = $hits->next ) {
print "$hit->{Shoes}\t$hit->{ID}\n";
}

After I run server on one shell, I execute the client on another shell, however, I get the following error:

Missing required parameter: 'schema'
cfish_XSBind_locate_args at xs/XSBind.c line 441
at /home/r/perl5/perlbrew/perls/perl-5.24.0/lib/site_perl/5.24.0/x86_64-linux/LucyX/Remote/SearchClient.pm line 35.
LucyX::Remote::SearchClient::new("LucyX::Remote::SearchClient", "peer_address", "localhost:7890") called at client.pl line 13


When I run a regular lucy search script like below, it runs fine.

#search.pl
#!/perl/bin/perl

use strict;
use warnings;
use Lucy::Search::IndexSearcher;
use Array::Utils qw(:all);

my $searcher = Lucy::Search::IndexSearcher->new(
index => 'indexdir'
);

my $hits = $searcher->hits( query => "nike" );
while ( my $hit = $hits->next ) {
print "$hit->{Shoes}\t$hit->{ID}\n";
}

Any suggestions on how to run Lucy in client, server mode?

One other related query, how can I perform search (in e.g. search.pl script above) on a specific column in a tabular data rather than the default mode of searching all columns together. So, something like: 'my $hits = $searcher->hits( query => "Shoes:nike" );' ?

Thank you,
Raja
Reply | Threaded
Open this post in threaded view
|

Re: [lucy-user] Lucy client/server

Nick Wellnhofer
On 26/10/2017 19:57, raja raja wrote:
> Any suggestions on how to run Lucy in client, server mode?

Lucy doesn't really offer a client/server mode. LucyX::Remote is a more or
less experimental feature for clustering and not what you seem to expect. It
requires the full schema and a Lucy library on the client.

I'd suggest to either roll your own search server over HTTP or use a solution
like Dezi which runs on top of Lucy:

     https://metacpan.org/pod/Dezi

> One other related query, how can I perform search (in e.g. search.pl script above) on a specific column in a tabular data rather than the default mode of searching all columns together. So, something like: 'my $hits = $searcher->hits( query => "Shoes:nike" );' ?

Either use a QueryParser with set_heed_colons set to true or create your query
manually using query objects:

     http://lucy.apache.org/docs/perl/Lucy/Search/QueryParser.html
     http://lucy.apache.org/docs/perl/Lucy/Docs/Tutorial/QueryObjectsTutorial.html

Nick