Skip Menu |

This queue is for tickets about the WebService-Solr CPAN distribution.

Report information
The Basics
Id: 86833
Status: open
Priority: 0/
Queue: WebService-Solr

People
Owner: Nobody in particular
Requestors: solr [...] elyograg.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Unable to query for all documents (*:*)
Date: Wed, 10 Jul 2013 10:40:30 -0600
To: bug-WebService-Solr [...] rt.cpan.org
From: Shawn Heisey <solr [...] elyograg.org>
I cannot figure out how to send a query for all documents. Using the new method on the Query object with a value of *:* throws an error: Code: 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'}); Error: 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. The WebService-Solr module is installed from CPAN into the packaged perl 5.14.2 in debian wheezy. I got the same error when using debian's packaged version of the WebService-Solr package. Separate but related problem: I tried to do a range query on my uniqueKey field of '[* TO *]' but the module escapes the special characters and they become a literal search string rather than a Solr range query. The query works, but returns zero results because there's nothing in the index that matches.
Subject: Re: [rt.cpan.org #86833] AutoReply: Unable to query for all documents (*:*)
Date: Wed, 10 Jul 2013 10:49:54 -0600
To: bug-WebService-Solr [...] rt.cpan.org
From: Shawn Heisey <solr [...] elyograg.org>
With help from alester in #solr, I was able to get that separate issue fixed, by passing a reference to the string rather than the literal string. my $query = WebService::Solr::Query->new({field => \'[* TO *]'}); This isn't very efficient because range queries in Solr are fairly slow, but it does work. Being able to send an all_documents query (*:*) would be much better.
The pod for WebService::Solr::Query gives an example of a query for all documents. Literal Queries Specifying a scalar ref as a value in a key-value pair will allow arbitrary queries to be sent across the line. NB: This will bypass any data massaging done on regular strings, thus the onus of properly escaping the data is left to the user. my $q = WebService::Solr::Query->new( { '*' => \'*' } ) # RESULT (*:*) I wrote a patch to add a shortcut method to do this, which I'm submitting to the maintainer. On Wed Jul 10 12:50:16 2013, solr@elyograg.org wrote: Show quoted text
> With help from alester in #solr, I was able to get that separate issue > fixed, by passing a reference to the string rather than the literal string. > > my $query = WebService::Solr::Query->new({field => \'[* TO *]'}); > > This isn't very efficient because range queries in Solr are fairly slow, > but it does work. Being able to send an all_documents query (*:*) would > be much better. >
Subject: patch.txt
Proposed Patch for adding shortcut method for select_all to WebService::Solr::Query Query.pm sub select_all { return '(*:*)' } =head2 select_all select_all is a shortcut to generate a query for *:* to select all documents. query.t my $query_all = WebService::Solr::Query->select_all() ; is ( "$query_all" , '(*:*)' , 'select_all (*:*)' ) ; live.t # change this value to the number of docs in your collection. my $docsincollection = 10 ; my $response = $solr->search( WebService::Solr::Query->select_all() ) ; my @WSR = $response->docs ; is ( scalar(@WSR), $docsincollection , "select_all returns $docsincollection docs." );