params => [
{name => 'arghash', desc => 'Arg hash (see open-ils.search.biblio.multiclass)', type => 'object'},
{name => 'query', desc => 'Raw human-readable query (see perldoc '. __PACKAGE__ .')', type => 'string'},
- {name => 'docache', desc => 'Flag for caching (see open-ils.search.biblio.multiclass)', type => 'bool'},
- {name => 'return_abstract', desc => "A flag to enable/disable returning an abstract represenation of the query itself, in addition to the result set (default OFF)", type => 'bool'}
+ {name => 'docache', desc => 'Flag for caching (see open-ils.search.biblio.multiclass)', type => 'bool'}
],
return => {
desc => 'Search results from query, like: { "count" : $count, "ids" : [ [ $id, $relevancy, $total ], ...] }',
}
sub multiclass_query {
- my($self, $conn, $arghash, $query, $docache, $return_abstract) = @_;
+ my($self, $conn, $arghash, $query, $docache) = @_;
$logger->debug("initial search query => $query");
my $orig_query = $query;
# unless $arghash->{preferred_language};
$method = $self->method_lookup($method);
- my ($data) = $method->run($arghash, $docache, $return_abstract);
+ my ($data) = $method->run($arghash, $docache);
$arghash->{searches} = $search if (!$data->{complex_query});
{
desc => "A flag to enable/disable searching and saving results in cache, including facets (default OFF)",
type => 'bool'
- },
- {
- desc => "A flag to enable/disable returning an abstract represenation of the query itself, in addition to the result set (default OFF)",
- type => 'bool'
}
],
return => {
);
sub staged_search {
- my($self, $conn, $search_hash, $docache, $return_abstract) = @_;
+ my($self, $conn, $search_hash, $docache) = @_;
my $IAmMetabib = ($self->api_name =~ /metabib/) ? 1 : 0;
my $page; # current superpage
my $est_hit_count = 0;
my $current_page_summary = {};
- my $current_abstract = {};
my $global_summary = {checked => 0, visible => 0, excluded => 0, deleted => 0, total => 0};
my $is_real_hit_count = 0;
my $new_ids = [];
my $data = $cache_data->{$page};
my $results;
- my ($summary, $abstract);
+ my $summary;
$logger->debug("staged search: analyzing superpage $page");
$logger->debug("staged search: found cached results");
$summary = $data->{summary};
$results = $data->{results};
- $abstract = pop @$results;
} else {
# retrieve the window of results from the database
$logger->debug("staged search: fetching results from the database");
$search_hash->{skip_check} = $page * $superpage_size;
my $start = time;
$results = $U->storagereq($method, %$search_hash);
- $abstract = pop @$results;
$search_duration = time - $start;
$summary = shift(@$results) if $results;
if $search_hash->{tag_circulated_records} and $search_hash->{authtoken};
$current_page_summary = $summary;
- $current_abstract = $abstract;
# add the new set of results to the set under construction
push(@$all_results, @$results);
superpage_size => $search_hash->{check_limit},
superpage_summary => $current_page_summary,
facet_key => $facet_key,
- ids => \@results,
- ($return_abstract ? (abstract_query => $current_abstract) : ())
+ ids => \@results
}
);
$VERSION = 1;
+sub _initialize_parser {
+ my ($parser) = @_;
+
+ my $cstore = OpenSRF::AppSession->create( 'open-ils.cstore' );
+ $parser->initialize(
+ config_record_attr_index_norm_map =>
+ $cstore->request(
+ 'open-ils.cstore.direct.config.record_attr_index_norm_map.search.atomic',
+ { id => { "!=" => undef } },
+ { flesh => 1, flesh_fields => { crainm => [qw/norm/] }, order_by => [{ class => "crainm", field => "pos" }] }
+ )->gather(1),
+ search_relevance_adjustment =>
+ $cstore->request(
+ 'open-ils.cstore.direct.search.relevance_adjustment.search.atomic',
+ { id => { "!=" => undef } }
+ )->gather(1),
+ config_metabib_field =>
+ $cstore->request(
+ 'open-ils.cstore.direct.config.metabib_field.search.atomic',
+ { id => { "!=" => undef } }
+ )->gather(1),
+ config_metabib_search_alias =>
+ $cstore->request(
+ 'open-ils.cstore.direct.config.metabib_search_alias.search.atomic',
+ { alias => { "!=" => undef } }
+ )->gather(1),
+ config_metabib_field_index_norm_map =>
+ $cstore->request(
+ 'open-ils.cstore.direct.config.metabib_field_index_norm_map.search.atomic',
+ { id => { "!=" => undef } },
+ { flesh => 1, flesh_fields => { cmfinm => [qw/norm/] }, order_by => [{ class => "cmfinm", field => "pos" }] }
+ )->gather(1),
+ config_record_attr_definition =>
+ $cstore->request(
+ 'open-ils.cstore.direct.config.record_attr_definition.search.atomic',
+ { name => { "!=" => undef } }
+ )->gather(1),
+ );
+
+ $cstore->disconnect;
+ die("Cannot initialize $parser!") unless ($parser->initialization_complete);
+}
+
sub ordered_records_from_metarecord {
my $self = shift;
my $client = shift;
}
);
-## XXX The following str2abstract_query stuff doesn't work, but do we need it
-## to? Is this the right place for it? for now, you *can* get an abstract query
-## back as part of the result if you call
-## open-ils.search.biblio.multiclass.query with appropriate args.
-## I suspect all we need to do (other than uncommenting the use statement
-## near the top) is OpenILS::...::QueryParser->TEST_SETUP;, but I'm not sure
-## that actually makes sense within the storage app.
-#
-#sub str2abstract_query {
-# my ($self, $conn, $query, $opts) = @_;
-#
-# my %use_opts = ( # reasonable defaults? should these even be hardcoded here?
-# superpage => 1,
-# superpage_size => 1000,
-# core_limit => 25000,
-# query => $query,
-# (ref $opts eq 'HASH' ? %$opts : ())
-# );
-#
-# my $plan = new
-# OpenILS::Application::Storage::Driver::Pg::QueryParser(%use_opts);
-#
-# return $plan->parse_tree->to_abstract_query;
-#}
-#
-#__PACKAGE__->register_method(
-# api_name => "open-ils.storage.query_parser.abstract_query.from_string",
-# method => "str2abstract_query",
-# api_level => 1,
-# signature => {
-# params => [
-# {desc => "Query", type => "string"},
-# {desc => "arguments to QueryParser constructor (optional)", type => "object"}
-# ],
-# return => { type => "object", desc => "abstract representation of query parser query" }
-# }
-#);
+sub str2abstract_query {
+ my ($self, $conn, $query, $qp_opts, $with_config) = @_;
+
+ my %use_opts = ( # reasonable defaults? should these even be hardcoded here?
+ superpage => 1,
+ superpage_size => 1000,
+ core_limit => 25000,
+ query => $query,
+ (ref $opts eq 'HASH' ? %$opts : ())
+ );
+
+ $with_config ||= 0;
+
+ # grab the query parser and initialize it
+ my $parser = $OpenILS::Application::Storage::QParser;
+ $parser->use;
+
+ _initialize_parser($parser) unless $parser->initialization_complete;
+
+ my $query = $parser->new(%use_opts)->parse;
+
+ return $query->parse_tree->to_abstract_query(with_config => $with_config);
+}
+
+__PACKAGE__->register_method(
+ api_name => "open-ils.storage.query_parser.abstract_query.from_string",
+ method => "str2abstract_query",
+ api_level => 1,
+ signature => {
+ params => [
+ {desc => "Query", type => "string"},
+ {desc => q/Arguments for initializing QueryParser (optional)/,
+ type => "object"},
+ {desc => q/Flag enabling inclusion of QP config in returned object (optional, default false)/,
+ type => "bool"}
+ ],
+ return => { type => "object", desc => "abstract representation of query parser query" }
+ }
+);
sub query_parser_fts {
my $self = shift;
my $parser = $OpenILS::Application::Storage::QParser;
$parser->use;
- if (!$parser->initialization_complete) {
- my $cstore = OpenSRF::AppSession->create( 'open-ils.cstore' );
- $parser->initialize(
- config_record_attr_index_norm_map =>
- $cstore->request(
- 'open-ils.cstore.direct.config.record_attr_index_norm_map.search.atomic',
- { id => { "!=" => undef } },
- { flesh => 1, flesh_fields => { crainm => [qw/norm/] }, order_by => [{ class => "crainm", field => "pos" }] }
- )->gather(1),
- search_relevance_adjustment =>
- $cstore->request(
- 'open-ils.cstore.direct.search.relevance_adjustment.search.atomic',
- { id => { "!=" => undef } }
- )->gather(1),
- config_metabib_field =>
- $cstore->request(
- 'open-ils.cstore.direct.config.metabib_field.search.atomic',
- { id => { "!=" => undef } }
- )->gather(1),
- config_metabib_search_alias =>
- $cstore->request(
- 'open-ils.cstore.direct.config.metabib_search_alias.search.atomic',
- { alias => { "!=" => undef } }
- )->gather(1),
- config_metabib_field_index_norm_map =>
- $cstore->request(
- 'open-ils.cstore.direct.config.metabib_field_index_norm_map.search.atomic',
- { id => { "!=" => undef } },
- { flesh => 1, flesh_fields => { cmfinm => [qw/norm/] }, order_by => [{ class => "cmfinm", field => "pos" }] }
- )->gather(1),
- config_record_attr_definition =>
- $cstore->request(
- 'open-ils.cstore.direct.config.record_attr_definition.search.atomic',
- { name => { "!=" => undef } }
- )->gather(1),
- );
-
- $cstore->disconnect;
- die("Cannot initialize $parser!") unless ($parser->initialization_complete);
- }
-
+ _initialize_parser($parser) unless $parser->initialization_complete;
# populate the locale/language map
if (!$locale_map{COMPLETE}) {
$client->respond( $rec );
}
- $client->respond($query->parse_tree->to_abstract_query(with_config => 1));
return undef;
}
__PACKAGE__->register_method(