From: Bill Erickson Date: Wed, 11 Sep 2019 21:30:31 +0000 (-0400) Subject: add more sample searches X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6b37cbbb7a976a62f91a0ed933f19af03fbf62d3;p=working%2FEvergreen.git add more sample searches Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/support-scripts/test-scripts/elastic-search.pl b/Open-ILS/src/support-scripts/test-scripts/elastic-search.pl index a49a909909..1a8fb178e7 100755 --- a/Open-ILS/src/support-scripts/test-scripts/elastic-search.pl +++ b/Open-ILS/src/support-scripts/test-scripts/elastic-search.pl @@ -27,7 +27,7 @@ sub help { $0 - Performs a canned bib record search + Performs a series of canned bib record searches HELP exit(0); @@ -35,19 +35,9 @@ HELP help() if $help; -# connect to osrf... -OpenSRF::System->bootstrap_client(config_file => $osrf_config); -Fieldmapper->import( - IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL")); -OpenILS::Utils::CStoreEditor::init(); +my $queries = [{ -# Title search AND subject search AND MARC tag=100 search -my $query = { - _source => ['id', 'title|maintitle'] , # return only the ID field - from => 0, - size => 5, - sort => [{'_score' => 'desc'}], - query => { + # Title search AND subject search AND MARC tag=100 search bool => { must => [{ multi_match => { @@ -83,25 +73,70 @@ my $query = { } }] } - } -}; +}, { + # Author search + bool => { + must => [{ + multi_match => { + query => 'Cuthbert Morton Girdlestone', + fields => ['author|*text*'], + operator => 'and', + type => 'most_fields' + } + }] + } +}, { + # Personal author exact match search + bool => { + must => [{ + term => {'author|personal' => 'Rowling, J. K.'} + }] + } +}, { + # Main title search + bool => { + must => [{ + multi_match => { + query => 'ready player', + fields => ['title|maintitle.text*'], + operator => 'and', + type => 'most_fields' + } + }] + } +}]; -my $es = OpenILS::Elastic::BibSearch->new($cluster); +# connect to osrf... +print "Connecting...\n"; +OpenSRF::System->bootstrap_client(config_file => $osrf_config); +Fieldmapper->import( + IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL")); +OpenILS::Utils::CStoreEditor::init(); +my $es = OpenILS::Elastic::BibSearch->new($cluster); $es->connect; -print OpenSRF::Utils::JSON->perl2JSON($query) . "\n\n"; +print "Searching...\n"; +for my $query_part (@$queries) { + + my $query = { + _source => ['id', 'title|maintitle'] , # return only the ID field + from => 0, + size => 5, + sort => [{'_score' => 'desc'}], + query => $query_part + }; -my $start = time(); -my $results = $es->search($query); -my $duration = substr(time() - $start, 0, 6); + print OpenSRF::Utils::JSON->perl2JSON($query) . "\n\n" unless $quiet; -print OpenSRF::Utils::JSON->perl2JSON($results) . "\n"; + my $start = time(); + my $results = $es->search($query); + my $duration = substr(time() - $start, 0, 6); -unless ($quiet) { - print "\nSearch returned ".$results->{hits}->{total}. + print OpenSRF::Utils::JSON->perl2JSON($results) . "\n\n" unless $quiet; + + print "Search returned ".$results->{hits}->{total}. " hits with a reported duration of ".$results->{took}."ms.\n"; - print "Full round-trip time was $duration seconds.\n"; + print "Full round-trip time was $duration seconds.\n\n"; } -