]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/query_tests.pl
Fix boolean lists; Better atom regex; Caching
[working/Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / query_tests.pl
1 #!/usr/bin/perl
2 require '../oils_header.pl';
3 use strict; use warnings;
4 use OpenSRF::EX qw(:try);
5 use OpenSRF::AppSession;
6 use Getopt::Long;
7 use Data::Dumper;
8
9 my $config = '/openils/conf/opensrf_core.xml';
10 my $debug = 0;
11 my @default_queries = (
12     'keyword1',
13     'keyword1 || keyword2',
14     '(keyword1) || keyword2',
15     'keyword1 || (keyword2)',
16     '(keyword1) || (keyword2)',
17     'keyword item_type(a)',
18     '(item_type(a)) keyword1',
19     'keyword1 item_type(a) title:keyword2',
20     'keyword1 (item_type(a)) title:keyword2',
21     'item_type(a) keyword1 title:keyword2',
22     '(item_type(a)) keyword1 title:keyword2',
23     'concerto',
24     'concerto (violin || piano)',
25     '-keyword1',
26     '-"keyword1"',
27     'keyword:"keyword1"',
28     'keyword:"keyword1" title:"keyword2"',
29     'keyword locations() statuses()',
30 # A small set of searches that errored out in a production install
31     'keyword: subject:Graphical user interfaces (Computer systems) depth(0) subject|topic[Authoring programs]',
32     'keyword: subject:Assassins New York (State) depth(0) subject|geographic[Buffalo (N.Y.)]',
33     'keyword: author: Niggeman Indifilm (Firm) depth(0) subject|geographic[Mars (Planet)]',
34     'keyword: subject:Los Angeles (Calif.) Juvenile fiction. depth(0) subject|geographic[Los Angeles (Calif.)]',
35     'keyword: subject:Los Angeles (Calif.) depth(0) subject|geographic[California] subject|name[Faulkner, William 1897-1962]',
36     'keyword: subject:Thrillers (Motion pictures, television, etc.) depth(0) subject|topic[Action and adventure films]',
37     'keyword: author: Brilliance Audio (Firm) depth(0) subject|topic[Man-woman relationships]',
38     'keyword: subject:Rhodenbarr, Bernie (Fictitious character) depth(0) subject|geographic[England] subject|topic[Audiocassettes]',
39     'keyword: subject:Burgett, Donald R. (Donald Robert), depth(0) subject|geographic[Netherlands]',
40     'keyword: author: 2 Entertain (Firm) depth(0) subject|geographic[England] subject|geographic[Nottingham (England)]',
41 # Selection from the query_parser.pl script
42     '#available title: foo bar* || (-baz || (subject:"1900'.
43                         '-1910 junk" "and another thing" se:stuff #available '.
44                         'statuses(0,7,12))) && && && au:malarky || au|'.
45                         'corporate|personal:gonzo && dc.identifier:+123456789X'.
46                         ' dc.contributor=rowling #metarecord estimation_'.
47                         'strategy(exclusion) item_type(a, t) item_form(d) '.
48                         'bib.subjectTitle=potter bib.subjectName=harry '.
49                         'keyword|mapscale:1:250000',
50     'concerto #available filter_group_entry(1,2,3) filter_group_entry(4,5)',
51     'concerto || filter_group_entry(4) || filter_group_entry(3)',
52     'concerto (audience(a) || (item_type(a) && item_form(b)))',
53     'concerto || (piano && (item_type(a) || audience(a)))',
54     '(concerto item_type(a)) || (piano item_type(b))',
55     'audience(a) (concerto || item_type(a) || (piano music item_form(b)))',
56     'concerto && (item_type(a) || piano) && (item_form(b) || music)',
57     'concerto && (piano || item_type(a)) && (music || item_form(b))',
58     'Cancer du sujet {circ}ag{acute}e',
59     'a || b || c || d || e || f || g || h || i || j || k || l || m || n || o || p || q || r || s || t || u || v || w || x || y || z', # will run afoul of depth restrictions 
60
61 );
62
63 my @queries;
64
65 GetOptions(
66     'config=s' => \$config,
67     'debug' => \$debug,
68     'query=s' => \@queries,
69 );
70 osrf_connect($config); # connect to jabber
71
72 @queries = @default_queries unless @queries;
73
74 my $ses = OpenSRF::AppSession->create("open-ils.search");
75 $ses->connect;
76 print "Running Queries\n";
77 foreach (@queries) {
78     try {
79         my $req = $ses->request('open-ils.search.biblio.multiclass.query', {}, $_, 0);
80         my $stat = $req->gather(1);
81         print "Query $_ returned " . $stat->{count} . " results\n";
82     } catch Error with {
83         print "ERROR ON QUERY: $_\n";
84     };
85 }
86 print "Done\n";
87 $ses->disconnect;
88
89