SolrDocument - change to a mixin?

13 views
Skip to first unread message

matt mitchell

unread,
Apr 6, 2009, 1:35:34 PM4/6/09
to Blacklight Development
Whahoo! I'm first :)

I was just chatting with Molly about a problem she was having. She was
getting an error when trying to call the has? method on a solr
document.

has? is a helper method that makes it easy to find out if a document
has a certain field or even a value within a given field (multi-values
fields). This method call is all over in the UVa code and I think it's
pretty useful. It is mixed-in to solr documents by the rsolr-ext
library, in SolrHelper. An example would be:

doc.has?(:location_facet, /Clemons/) => Boolean
doc.has?(:marc_display) => Boolean

The problem is that we are now wrapping those hashes in SolrDocument
classes so "has?" no longer exists.

We could either create a has? method in SolrDocument to forward to the
original methods, implement method_missing OR mixin a module that
provides the same behaviors as the existing SolrDocument class. I
personally would like to see it done as a mixin inside of SolrHelper,
and only mix it into documents that actually have a marc related feld.
So the SolrDocument class would become a SolrMARCDocument module.

What do you all think?

matt mitchell

unread,
Apr 6, 2009, 1:39:23 PM4/6/09
to Blacklight Development
The class module would become this module: http://gist.github.com/90853

Matt

Jamie Orchard-Hays

unread,
Apr 6, 2009, 1:47:12 PM4/6/09
to blacklight-...@googlegroups.com
Wow, I was waiting for Google to approve my spam-mailing addition of
the old group before I made the announcement (they moderated it and
said it would take 1 to 2 biz das). I guess they did it already
without notifying me!

Jamie

Naomi Dushay

unread,
Apr 6, 2009, 2:58:04 PM4/6/09
to blacklight-...@googlegroups.com
The idea was for SolrDocument to NOT be marc centric, eventually, I
thought. So if these methods are more about solr fields, then however
it makes sense to the ruby experts works for me.

Jessie is currently working on the marc21 slurp and tests, but
presumably his work would easily carry over?

- Naomi

matt mitchell

unread,
Apr 7, 2009, 12:01:05 PM4/7/09
to Blacklight Development
Hi Naomi,

I'm sure that whatever Jessie is working on could be converted to a
module. We can wait on this until he's done; one more use case would
help to show any possible problems with this idea.

Matt

Molly Pickral Cadieux

unread,
Apr 7, 2009, 2:41:42 PM4/7/09
to blacklight-...@googlegroups.com
Another helper method from the rsolr-ext library I really find helpful
(and is used pretty extensively in the current production UVa
implementation) is the "get" method. See:

http://github.com/mwmitchell/rsolr-ext/blob/ad8e4a66a0cb92d8ee6cf58e4bad1a0c9e1db095/lib/rsolr-ext/response/docs.rb

How are people feeling about Matt's various thought on making this
method and the has? method available to SolrDocuments?

Molly

Naomi Dushay

unread,
Apr 7, 2009, 3:54:39 PM4/7/09
to blacklight-...@googlegroups.com
Works for me if it's not marc centric. MarcDoc should be a subclass
of SolrDoc - Naomi

Erik Hatcher

unread,
Apr 7, 2009, 3:57:59 PM4/7/09
to blacklight-...@googlegroups.com

On Apr 7, 2009, at 3:54 PM, Naomi Dushay wrote:

>
> Works for me if it's not marc centric. MarcDoc should be a subclass
> of SolrDoc - Naomi

or a module plugin to a SolrDocument ;)

Erik

Matt Mitchell

unread,
Apr 16, 2009, 7:43:32 PM4/16/09
to blacklight-...@googlegroups.com
How would you all feel about me working on this tomorrow?

Matt

Bess Sadler

unread,
Apr 16, 2009, 7:49:50 PM4/16/09
to blacklight-...@googlegroups.com
+1!!

Yes, Matt it would be awesome if you had time to work on this tomorrow, thank you. 

Bess

Naomi Dushay

unread,
Apr 16, 2009, 8:41:58 PM4/16/09
to blacklight-...@googlegroups.com
Please check in with Jessie - I think he might have done something with this already.  Or ... you could look at the code he just checked in ...

- Naomi

Matt Mitchell

unread,
Apr 16, 2009, 9:45:45 PM4/16/09
to blacklight-...@googlegroups.com
Hi Naomi,

I see that Jessie created a BlacklightMarc module in lib and it all looks great!

My idea was that each solr document that is returned from SolrHelper, would be a hash that has "mixins" from (possibly multiple) modules depending on the fields present. So for example, if a document does not have a marc_display field, it doesn't get the marc behaviors that come from a marc module/mixin. It will allow us to dynamically mix and match behaviors instead of being locked in to a single class hierarchy or swaping different classes in and out.

Jessie's work doesn't prevent any of this from happening by the way. It should be able to stay like it is. I'd probably put it inside of the Blacklight module like Blacklight::Marc - instead of BlacklightMarc though.

Matt

Jessie Keck

unread,
Apr 17, 2009, 11:58:37 AM4/17/09
to blacklight-...@googlegroups.com
When I was thinking of how I wanted to code the BlacklightMarc module, I
was keeping this in mind. I tried to code it so the SolrDocument could
be turned into a module/mixin with little or no change the
BlacklightMarc module.

-Jessie Keck
Reply all
Reply to author
Forward
0 new messages