Lines 19-38
ok($QParser->load_config('./etc/searchengine/queryparser.yaml'), 'Loaded QP conf
Link Here
|
19 |
is($QParser->search_class_count, 4, 'Initialized 4 search classes'); |
19 |
is($QParser->search_class_count, 4, 'Initialized 4 search classes'); |
20 |
is (scalar(@{$QParser->search_fields()->{'keyword'}}), 111, "Correct number of search fields for 'keyword' class"); |
20 |
is (scalar(@{$QParser->search_fields()->{'keyword'}}), 111, "Correct number of search fields for 'keyword' class"); |
21 |
|
21 |
|
22 |
is($QParser->target_syntax('biblioserver', 'smith'), '@or @or @attr 1=1016 @attr 4=6 "smith" @attr 9=20 @attr 2=102 @attr 4=6 "smith" @attr 9=34 @attr 2=102 @attr 4=6 "smith"', 'super simple keyword query'); |
22 |
# Set keyword search as the default |
23 |
is($QParser->target_syntax('biblioserver', 'au:smith'), '@attr 1=1003 @attr 4=6 "smith"', 'simple author query'); |
23 |
$QParser->default_search_class('keyword'); |
24 |
is($QParser->target_syntax('biblioserver', 'keyword|publisher:smith'), '@attr 1=1018 @attr 4=6 "smith"', 'fielded publisher query'); |
24 |
|
25 |
is($QParser->target_syntax('biblioserver', 'ti:"little engine that could"'), '@attr 1=4 @attr 4=1 "little engine that could"', 'phrase query'); |
25 |
my $kwd_search = q/@attr 1=1016 @attr 4=6/; |
26 |
is($QParser->target_syntax('biblioserver', 'keyword|titlekw:smith'), '@attr 1=4 @attr 9=20 @attr 2=102 @attr 4=6 "smith"', 'relevance-bumped query'); |
26 |
my $weight1 = q/@attr 2=102 @attr 9=20 @attr 4=6/; |
27 |
is($QParser->target_syntax('biblioserver', 'au:smith && johnson'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 1=1003 @attr 4=6 "johnson"', 'query with boolean &&'); |
27 |
my $weight2 = q/@attr 2=102 @attr 9=34 @attr 4=6/; |
28 |
is($QParser->target_syntax('biblioserver', 'au:smith && ti:johnson'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 1=4 @attr 4=6 "johnson"', 'query with boolean &&'); |
28 |
|
29 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(-2008)'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 4=4 @attr 1=31 @attr 2=2 "2008"', 'keyword search with pubdate limited to -2008'); |
29 |
like( $QParser->target_syntax('biblioserver', 'smith'), |
30 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(2008-)'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 4=4 @attr 1=31 @attr 2=4 "2008"', 'keyword search with pubdate limited to 2008-'); |
30 |
qr/\@or \@or $kwd_search "smith" ($weight1 "smith" $weight2 "smith"|$weight2 "smith" $weight1 "smith")/, |
31 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(2008)'), '@and @attr 1=1003 @attr 4=6 "smith" @attr 4=4 @attr 1=31 "2008"', 'keyword search with pubdate limited to 2008'); |
31 |
'super simple keyword query'); |
32 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(1980,2008)'), '@and @attr 1=1003 @attr 4=6 "smith" @or @attr 4=4 @attr 1=31 "1980" @attr 4=4 @attr 1=31 "2008"', 'keyword search with pubdate limited to 1980, 2008'); |
32 |
|
33 |
is($QParser->target_syntax('biblioserver', 'au:smith #acqdate_dsc'), '@or @attr 1=32 @attr 7=1 0 @attr 1=1003 @attr 4=6 "smith"', 'keyword search sorted by acqdate descending'); |
33 |
is($QParser->target_syntax('biblioserver', 'au:smith'), |
34 |
is($QParser->bib1_mapping_by_attr('field', 'biblioserver', {'1' => '1004'})->{'field'}, 'personal', 'retrieve field by attr'); |
34 |
'@attr 1=1003 @attr 4=6 "smith"', 'simple author query'); |
35 |
is($QParser->bib1_mapping_by_attr_string('field', 'biblioserver', '@attr 1=1004')->{'field'}, 'personal', 'retrieve field by attrstring'); |
35 |
|
|
|
36 |
is($QParser->target_syntax('biblioserver', 'keyword|publisher:smith'), |
37 |
'@attr 1=1018 @attr 4=6 "smith"', 'fielded publisher query'); |
38 |
|
39 |
is($QParser->target_syntax('biblioserver', 'ti:"little engine that could"'), |
40 |
'@attr 1=4 @attr 4=1 "little engine that could"', 'phrase query'); |
41 |
|
42 |
is($QParser->target_syntax('biblioserver', 'keyword|titlekw:smith'), |
43 |
'@attr 1=4 @attr 2=102 @attr 9=20 @attr 4=6 "smith"', |
44 |
'relevance-bumped query'); |
45 |
|
46 |
is($QParser->target_syntax('biblioserver', 'au:smith && johnson'), |
47 |
'@and @attr 1=1003 @attr 4=6 "smith" @attr 1=1003 @attr 4=6 "johnson"', |
48 |
'query with boolean &&'); |
49 |
|
50 |
is($QParser->target_syntax('biblioserver', 'au:smith && ti:johnson'), |
51 |
'@and @attr 1=1003 @attr 4=6 "smith" @attr 1=4 @attr 4=6 "johnson"', 'query with boolean &&'); |
52 |
|
53 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(-2008)'), |
54 |
'@and @attr 1=1003 @attr 4=6 "smith" @attr 1=31 @attr 4=4 @attr 2=2 "2008"', |
55 |
'keyword search with pubdate limited to -2008'); |
56 |
|
57 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(2008-)'), |
58 |
'@and @attr 1=1003 @attr 4=6 "smith" @attr 1=31 @attr 4=4 @attr 2=4 "2008"', |
59 |
'keyword search with pubdate limited to 2008-'); |
60 |
|
61 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(2008)'), |
62 |
'@and @attr 1=1003 @attr 4=6 "smith" @attr 1=31 @attr 4=4 "2008"', |
63 |
'keyword search with pubdate limited to 2008'); |
64 |
|
65 |
is($QParser->target_syntax('biblioserver', 'au:smith pubdate(1980,2008)'), |
66 |
'@and @attr 1=1003 @attr 4=6 "smith" @or @attr 1=31 @attr 4=4 "1980" @attr 1=31 @attr 4=4 "2008"', |
67 |
'keyword search with pubdate limited to 1980, 2008'); |
68 |
|
69 |
is($QParser->target_syntax('biblioserver', 'au:smith #acqdate_dsc'), |
70 |
'@or @attr 1=32 @attr 7=1 0 @attr 1=1003 @attr 4=6 "smith"', |
71 |
'keyword search sorted by acqdate descending'); |
72 |
|
73 |
is($QParser->bib1_mapping_by_attr('field', 'biblioserver', {'1' => '1004'})->{'field'}, |
74 |
'personal', 'retrieve field by attr'); |
75 |
|
76 |
is($QParser->bib1_mapping_by_attr_string('field', 'biblioserver', '@attr 1=1004')->{'field'}, |
77 |
'personal', 'retrieve field by attrstring'); |
36 |
|
78 |
|
37 |
is ($QParser->clear_all_mappings, $QParser, 'clear all mappings returns self'); |
79 |
is ($QParser->clear_all_mappings, $QParser, 'clear all mappings returns self'); |
38 |
is ($QParser->clear_all_configuration, $QParser, 'clear all configuration returns self'); |
80 |
is ($QParser->clear_all_configuration, $QParser, 'clear all configuration returns self'); |
39 |
- |
|
|