added --filter switch for more efficient search caching
b537320b
Hari Sekhon
committed
1 changed file
check_solr_query.pl
/check_solr_query.pl-3+6
/check_solr_query.pl
Add comment 19
Add comment 20 Tested on Solr 3.1, 3.6.2 and Solr / SolrCloud 4.x";
Add comment 21
Add comment 22 Minus  $VERSION = "0.4";
Add comment 22 Plus  $VERSION = "0.5";
Add comment 23
Add comment 24 use strict;
Add comment 25 use warnings;
Add comment 35 set_threshold_defaults(100, 2000);
Add comment 36
Add comment 37 my $query = "*:*";
Add comment 38 Plus  my $filter;
Add comment 38 39 my $num_docs_threshold = 1;
Add comment 39 40
Add comment 40 41 %options = (
Add comment 43 44 %solroptions_list_cores,
Add comment 44 45 %solroptions_context,
Add comment 45 46 "q|query=s" => [ \$query, "Query to send to Solr (defaults to \"*:*\")" ],
Add comment 47 Plus   "f|filter=s" => [ \$filter, "Filter to send to Solr, use instead of query in order to make better use of caching (optional)" ],
Add comment 46 48 "n|num-docs=s" => [ \$num_docs_threshold, "Minimum or range threshold for number of matching docs to expect in result for given query (default: 1)" ],
Add comment 47 49 %thresholdoptions,
Add comment 48 50 );
Add comment 49 Minus  splice @usage_order, 6, 0, qw/collection query num-docs list-collections list-cores http-context/;
Add comment 51 Plus  splice @usage_order, 6, 0, qw/collection query filter num-docs list-collections list-cores http-context/;
Add comment 50 52
Add comment 51 53 get_options();
Add comment 52 54
Add comment 56 58 $collection = validate_solr_collection($collection);
Add comment 57 59 $query or usage "query not defined";
Add comment 58 60 vlog_options "query", $query;
Add comment 61 Plus   vlog_options "filter", $filter if defined($filter);
Add comment 59 62 validate_thresholds(0, 0, { 'simple' => 'lower', 'positive' => 1, 'integer' => 1}, "num docs", $num_docs_threshold);
Add comment 60 63 validate_thresholds(0, 0, { 'simple' => 'upper', 'positive' => 1, 'integer' => 1});
Add comment 61 64 }
Add comment 70 73 list_solr_collections();
Add comment 71 74 list_solr_cores();
Add comment 72 75
Add comment 73 Minus  $json = query_solr($collection, $query);
Add comment 76 Plus  $json = query_solr($collection, $query, $filter);
Add comment 74 77
Add comment 75 78 # reuse specific error from get_field
Add comment 76 79 $num_found = get_field_int("response.numFound") unless defined($num_found);