lucene-ruby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: jruby and solrj
Date Mon, 06 Oct 2008 19:59:24 GMT
Unfortunately, to call varargs from JRuby (so I just learned from  
irc's #jruby), you have to do this:

   query.add_facet_field(['cat'].to_java :string)

anyway, for our solr-jruby purposes, i think we can stick to using the  
ModifiableSolrParams API instead of SolrQuery, but we still get  
varargs issues.

thankfully Ruby solves this relatively nicely...

   solr =, "core1")
   query =
   def query.abcd(key, values)
     add(key,(values.is_a?(Array) ? values : [values]).to_java(:string))
   response = solr.query(query)

We'll just need to sprinkle a little Ruby fairy dust on some of this  
clunky stuff.  It's not all that bad.  But the varargs one is strange  
to me, but I'm sure there is some deep technical reason why that  
support isn't intuitive.


On Oct 6, 2008, at 1:36 AM, Ryan McKinley wrote:

> just guessing, but try passing that as a string[] rather then just a  
> string
> The java function takes ( string ... v ) -- in java that means you  
> can pass either a string or an array, or a variable length list of  
> strings.  I'm guessing that does something funny with jruby
> ryan
> On Oct 5, 2008, at 10:54 PM, Matt Mitchell wrote:
>> I've been messing around with jRuby and SolrJ with nice results.  
>> But can't
>> seem to get the SolrQuery.addFacetField method to work. I get this  
>> error:
>> "for method addFacetField expected [[Ljava.lang.String;]; got:
>> [java.lang.String]; error: argument type mismatch (TypeError)"
>> I'm using it like:
>> query.add_facet_field 'cat'
>> and also tried:
>> query.addFacetField 'cat'
>> Any ideas as to what I'm doing wrong?
>> Matt
>> p.s. The other methods I've tried work great: set_query,  
>> set_query_type,
>> set_facet, set_facet_limit, set_facet_min_count, set_include_score,
>> add_sort_field.

View raw message