You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Shalin Shekhar Mangar <sh...@gmail.com> on 2009/03/08 07:18:57 UTC

Re: Type of object to go into NamedList as part of SearchComponent#process(ResponseBuilder rb)

On Sun, Mar 8, 2009 at 5:34 AM, Rakesh Sinha <ra...@gmail.com>wrote:

>
> client:
> --------
> QueryResponse rsp = commonsHttpSolrServer.query( mySolrQuery);
> MySerializableType obj  = rsp.getResponse().get("myresult");
>
> I was curious if the above mentioned code would work for any kind of
> serializable type , T, as long as it implements Serializable . Would
> there be any restrictions on the same (like only List of Strings -
> List of Integers etc).
> Thanks.
>

No, the returned object is a NamedList data structure. It can contain the
basic java types (int/float etc.), strings, lists, maps and a couple of Solr
specific objects such as SolrDocumentList, SolrDocument

http://lucene.apache.org/solr/api/solrj/org/apache/solr/common/util/NamedList.html
-- 
Regards,
Shalin Shekhar Mangar.

Re: Type of object to go into NamedList as part of SearchComponent#process(ResponseBuilder rb)

Posted by Chris Hostetter <ho...@fucit.org>.
: So  - is there any Solr code that I can look at - that imposes the
: restriction that the type has to be an int, string ,List (of what
: allowed objects ? ) . Map ( allowed key, value types ? )  etc.

see the javadocs for SolrQueryResponse...

http://lucene.apache.org/solr/api/org/apache/solr/request/SolrQueryResponse.html

The code won't prevent you from adding anything else, but if you do add 
something else, the ResponseWriters are free to output it however they see 
fit (usually by calling toString())



-Hoss


Re: Type of object to go into NamedList as part of SearchComponent#process(ResponseBuilder rb)

Posted by Rakesh Sinha <ra...@gmail.com>.
QueryResponse rsp = commonsHttpSolrServer.query( mySolrQuery);
MySerializableType obj  = rsp.getResponse().get("myresult");

In the code - the API referred to is -

http://lucene.apache.org/solr/api/org/apache/solr/common/util/NamedList.html#get(java.lang.String)
 .

That seems to return any object of type T , as per the API .

So  - is there any Solr code that I can look at - that imposes the
restriction that the type has to be an int, string ,List (of what
allowed objects ? ) . Map ( allowed key, value types ? )  etc.




On Sun, Mar 8, 2009 at 2:18 AM, Shalin Shekhar Mangar
<sh...@gmail.com> wrote:
> On Sun, Mar 8, 2009 at 5:34 AM, Rakesh Sinha <ra...@gmail.com>wrote:
>
>>
>> client:
>> --------
>> QueryResponse rsp = commonsHttpSolrServer.query( mySolrQuery);
>> MySerializableType obj  = rsp.getResponse().get("myresult");
>>
>> I was curious if the above mentioned code would work for any kind of
>> serializable type , T, as long as it implements Serializable . Would
>> there be any restrictions on the same (like only List of Strings -
>> List of Integers etc).
>> Thanks.
>>
>
> No, the returned object is a NamedList data structure. It can contain the
> basic java types (int/float etc.), strings, lists, maps and a couple of Solr
> specific objects such as SolrDocumentList, SolrDocument
>
> http://lucene.apache.org/solr/api/solrj/org/apache/solr/common/util/NamedList.html
> --
> Regards,
> Shalin Shekhar Mangar.
>