Perl Solr help - doing *:* query

2013-07-09 Thread Shawn Heisey

This is primarily to Andy Lester, who wrote the WebService::Solr module
on CPAN, but I'll take a response from anyone who knows what I can do.

If I use the following Perl code, I get an error.  If I try to build
some other query besides *:* to request all documents, the script runs,
but the query doesn't do what I asked it to do.

http://apaste.info/3j3Q

How can I use a perl script with a proper Solr API to count the number
of documents in my Solr index?

I already have a version of my script that parses a JSON response as
plain text, but as I have just learned, it's possible to get invalid
information out of it.  Specifically, the shards.info output has
multiple numFound instances in it, which broke my script.  The 
shards.info parameter is in the request handler defaults.  I'd like to

future-proof it by using actual objects.

Thanks,
Shawn


Re: Perl Solr help - doing *:* query

2013-07-09 Thread Andy Lester

On Jul 9, 2013, at 2:48 PM, Shawn Heisey s...@elyograg.org wrote:

 This is primarily to Andy Lester, who wrote the WebService::Solr module
 on CPAN, but I'll take a response from anyone who knows what I can do.
 
 If I use the following Perl code, I get an error.

What error do you get?  Never say I get an error.  Always say I get this 
error: .

  If I try to build
 some other query besides *:* to request all documents, the script runs,
 but the query doesn't do what I asked it to do.

What DOES it do?


 http://apaste.info/3j3Q

For the sake of future readers, please put your code in the message.  This 
message will get archived, and future people reading the lists will not be able 
to read the code at some arbitrary paste site.

Shawn's code is:

use strict;
use WebService::Solr;
use WebService::Solr::Query;
use WebService::Solr::Response;



my $url = http://idx.REDACTED.com:8984/solr/ncmain;;
my $solr = WebService::Solr-new($url);
my $query = WebService::Solr::Query-new(*:*);
my $response = $solr-search($query, {'rows' = '0'});
my $numFound = $response-content-{response}-{numFound};

print nf: $numFound\n;


xoa

--
Andy Lester = a...@petdance.com = www.petdance.com = AIM:petdance



Re: Perl Solr help - doing *:* query

2013-07-09 Thread Shawn Heisey

On 7/9/2013 2:02 PM, Andy Lester wrote:
What error do you get? Never say I get an error. Always say I get 
this error: . 


This is the actual error when trying *:* :

Can't locate object method _struct_ via package 
WebService::Solr::Query at 
/usr/local/share/perl/5.14.2/WebService/Solr/Query.pm line 37.



  If I try to build
some other query besides *:* to request all documents, the script runs,
but the query doesn't do what I asked it to do.

What DOES it do?


If I change the query line to this:

my $query = WebService::Solr::Query-new({tag_id = '[* TO *]'});

With this, numFound is zero.  The tag_id field is my uniqueKey, and is a 
StrField.  When I use Dumper to print out the actual response from this 
query, it contains the following info:


'q' = '(tag_id:\\[\\* TO \\*\\])',

I didn't ask for a phrase search (the quotes) or for escaping on the 
special query characters.  By automatically doing this, it makes complex 
queries like ranges impossible.  Is there something else that should be 
done for more complex queries?


Thanks,
Shawn