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 zqzuk <zi...@hotmail.co.uk> on 2013/05/07 22:43:21 UTC

Storing and retrieving Objects using ByteField

Hi

I need to store and retrieve some custom java objects using Solr and I have
used ByteField and java serialisation for this. Using the embedded jetty
server I can see these byte data but when I use Solrj api to retrieve the
data they are not available. Details are below:

My schema:
----------------------------------
<field name="id" type="string" indexed="true" stored="true" required="true"
multiValued="false" /> 
<field name="value" type="byte" indexed="false" stored="true"
multiValued="true" omitNorms="true"/> 
<fieldtype name="byte" class="solr.ByteField"/>
------------------------------------

My query using jetty embedded solr server:
--------------------------
http://localhost:8983/solr/collection1/select?q=id:1843921115&wt=xml&indent=true
-------------------------


And I can see the following results in the browser:
-----------------------------
esult name="response" numFound="1" start="0">
<doc>
<str name="id">1843921115</str>
<arr name="value">
<str>rO0ABXNyABNqYXZhLnV0aWwuQXJyYX......blahblahblah</str>
</arr>
<long name="_version_">1434407268842995712</long>
</doc>
-------------------------------------

So it looks like the data are created properly.

However, when I use SolrJ to retrieve this record like this:

-------------------
 ModifiableSolrParams params = new ModifiableSolrParams();
 params.set("q", "id:1843921115");
 QueryResponse response = server.query(params);
 SolrDocument doc = response.getResults().get(0);
 if(doc.getFieldValues("value")==null)
     System.out.println("data unavailable");
-------------------------------

I can see that "doc" only have two fields: id and version, and the field
"value" is never available.

Please suggestions what have I done wrong?

Many thanks!



--
View this message in context: http://lucene.472066.n3.nabble.com/Storing-and-retrieving-Objects-using-ByteField-tp4061418.html
Sent from the Solr - User mailing list archive at Nabble.com.