jackdoe/SHEEP
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
ALPHA - WORK IN PROGRESS
*alpha* not recommended for anything but hacking on some simple CLucene
examples
NAME
SHEEP - simple CLucene wrapper that spawns threads for every shard when
search()ing
SYNOPSIS
use SHEEP;
my $x = new SHEEP('/path/to/index',5) # create index with 5 shards
my @documents = ();
push @documents, { "name" => "jack doe", age => "200" }
for(1 .. 1_000);
push @documents, { "name" => "john doe", age => "300" }
for(1 .. 1_000);
$x->index(\@documents);
# find top 10 documents containing 'doe' in the name field
my $r = $x->search({ term => { name => 'doe' } }, 10);
# find top 10 documents containing 'doe' in the name,
# AND 200 in the 'age' field
my $r = $x->search({ term => { name => 'doe', age => '200' } }, 10);
# some bool query examples:
$x->search({
bool => {
must => [
{ term => { "name" => 'jack' } }
],
must_not => [
{ term => { "name" => 'john' } }
]
}
}, 10);
$x->search({
bool => {
must => [
{ term => { "name" => 'jack' } }
],
must_not => [
{ term => { "name" => 'jack' } }
]
}
}, 10);
$x->search({
bool => {
must => [
{ term => { "name" => 'jack' } }
],
should => [
{ term => { "name" => 'jim' } }
],
must_not => [
{ term => { "name" => 'john' } }
]
}
}, 10);
$x->search({
bool => {
must => [
{
bool => {
must => [ { term => { name => 'jack' } } ]
}
}
],
should => [
{ term => { name => 'jim' } }
],
must_not => [
{ term => { name => 'john' } }
]
}
}, 10);
DESCRIPTION
SHEEP is a simplistic non-flexible CLucene wrapper
It uses WhiteSpaceAnalyzer, and can work only with BooleanQueries and
Term queries. It also uses boost::thread to spawn new thread for every
shard when searching.
SEE ALSO
<http://clucene.sourceforge.net/>
<http://clucene.sourceforge.net/doc/html/namespaces.html>
<https://github.com/jackdoe/SHEEP>
AUTHOR
Borislav Nikolov <jack@sofialondonmoskva.com>
COPYRIGHT AND LICENSE
Copyright (C) 2013 by Borislav Nikolov
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.18.1 or, at
your option, any later version of Perl 5 you may have available.