Mailing List Archive

Working a Solr Model -- Follow Up
After trying to work with Apache::Solr and running into a brick wall
there, I went back to WebService::Solr and reread the documentation and
looked at the source code and decided to give it another try and start
over.

This time it worked, and I was able to return a
WebServer::Solr::Response object and pass it to the view. Comparing my
failed experiment with the working one I figured out what caused the
Unicode errors. I was even able to propose a patch to implement a minor
feature request that was sitting in the rt.cpan queue.

Summary of the 3 modules I looked at for implementing a Solr Model.

Rejected: Apache::Solr
Returned a resultset that didn't work in Template::Toolkit, had write
ugly code to convert to array of hashrefs.
I could not figure out how to use a filter query (they are absolutely
required for how I intend to use Solr).

Rejected: SolrBeam
Must download from GitHub instead of CPAN.
Despite the oddness of feeling like I was reading Ruby I was able to do
some debugging in the module, but still didn't get it to work.

Selected: WebService::Solr
You must read all of the submodule documentation, everything I needed to
figure out was somewhere in the documentation, but often not in the main
module's documentation.
Has its' own Model Adaptor, but it also works if you just extend
Catalyst::Model.
The code itself was comprehensible and I was able to logically trace a
request through it, and also to submit a very minor feature patch.
Implements the features I've tried to use so far.

I plan to write a how-to, which I'll post on my blog, if there is going
to be an Advent Calendar this year, let me know who is collecting
submissions for it and I'll submit the article in POD.





_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: Working a Solr Model -- Follow Up [ In reply to ]
On 06/10/2013, at 6:27 PM, John Karr <brainbuz@brainbuz.org> wrote:

> Rejected: Apache::Solr
> Returned a resultset that didn't work in Template::Toolkit, had write ugly code to convert to array of hashrefs.
> I could not figure out how to use a filter query (they are absolutely required for how I intend to use Solr).

Probably could have sorted this by passing the Solr resultset to a subref set to $c->stash. so you end up with something like [.% SET data = handle_stupid_resultset(data); WHILE (x = data.iterate); 'do stuff with ' _ x ; END; %] in your template. It's the poor man's approach to putting new object models in the template rendering engine.
Re: Working a Solr Model -- Follow Up [ In reply to ]
On 06/10/2013, at 6:27 PM, John Karr <brainbuz@brainbuz.org> wrote:

> Rejected: Apache::Solr
> Returned a resultset that didn't work in Template::Toolkit, had write ugly code to convert to array of hashrefs.
> I could not figure out how to use a filter query (they are absolutely required for how I intend to use Solr).

Probably could have sorted this by passing the Solr resultset to a subref set to $c->stash. so you end up with something like [.% SET data = handle_stupid_resultset(data); WHILE (x = data.iterate); 'do stuff with ' _ x ; END; %] in your template. It's the poor man's approach to putting new object models in the template rendering engine.
Re: Working a Solr Model -- Follow Up [ In reply to ]
More important than the ugly code to get output to display is that I
couldn't figure out how to use a necessary solr feature. Equivalent to a
DBD for a SQL database that doesn't support subqueries in a select.

Unfortunately, not all of my unicode woes have not been resolved, I have
a description field that is causing IO::Handle to throw a wide character
error on template rendering, and a bug reported for WebService::Solr
since there does after all appear to be a real unicode issue.

As a workaround I wrote a macro in Template::Toolkit.

[% MACRO utfclean(field) PERL %]
use utf8;
my $field = $stash->get('field');
utf8::encode($field);
print $field ;
[% END %]


On 10/06/2013 05:57 AM, Kieren Diment wrote:
>
> On 06/10/2013, at 6:27 PM, John Karr <brainbuz@brainbuz.org
> <mailto:brainbuz@brainbuz.org>> wrote:
>
>> Rejected: Apache::Solr
>> Returned a resultset that didn't work in Template::Toolkit, had write
>> ugly code to convert to array of hashrefs.
>> I could not figure out how to use a filter query (they are absolutely
>> required for how I intend to use Solr).
>
> Probably could have sorted this by passing the Solr resultset to a
> subref set to $c->stash. so you end up with something like [.% SET
> data = handle_stupid_resultset(data); WHILE (x = data.iterate); 'do
> stuff with ' _ x ; END; %] in your template. It's the poor man's
> approach to putting new object models in the template rendering engine.
>
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/