0

I am new to solr, and I am facing a problem when I try to serialize/deserialize a Map in Solr.

I use Spring Data Solr in my Java application as follow:

@Field("mapped_*")
private Map<String, String> values;

It flatten and serializes my map in Solr as follow:

"key1" : "value1"
"key2" : "value2"
...

However, when I run a search, the returned objects have this field always set as NULL. Deserialization does not work on this particular field, it looks like it does not recognize the key1, key2... as part of the Map.

Does anyone know how to make the derialization work? Do I have to implement a custom converter?

yohm
  • 452
  • 7
  • 14

1 Answers1

3

At this time Spring Data Solr does not automatically prefix values contained in the map with the given @Field#value, but will just use the Map#key as fieldname. There's an improvement (DATASOLR-202) open.

At this time having key1, key2,.. in values requires the fieldname to be key* in order to read back values correctly.

@Field("key*")
private Map<String, String> values;
Christoph Strobl
  • 6,491
  • 25
  • 33
  • `@Dynamic` has recently been added to Spring Data Solr - you can use `@Dynamic @Field("key*") Map values;` which will do the requested. The feature will be part of the Gosling release - you can already give the current `spring-data-solr:1.5.0.BUILD-SNAPSHOT` a spin. – Christoph Strobl Jun 03 '15 at 09:41