1

I have some fields in Solr that I'm currently mapping to Java like so:

@Field("file_*") @Dynamic private final Map<String, List<String>> fileDetails;

this matches a number of dynamic fields like:

file_name_1
file_type_1
file_size_1
...
file_name_2
file_type_2
file_size_2
...
...

I then convert that fileDetails map to a FileAttachments object to be used elsewhere in the code.

That is currently resulting in this class having some specific code for converting from how the data is stored in Solr, into the POJO.

Ideally, I'd want to map it more like so:

@Field("file_*") private final FileAttachments attachments;

or even better (but possibly even harder to accomplish):

@Field("file_*") private final List<FileAttachment> attachments;

Then (aside from annotations) the class knows nothing about how the data is stored in Solr.

However, the problem, is, when I try and use a custom convertor for the field (as detailed here), the convertor doesn't get passed a Map<String, List<String>> instance, holding all the fields that matched file_*, instead it simply gets passed a String instance, holding the value of the first field that matched the pattern.

Is there any way to get it to pass the Map<String, List<String>> instance, or any other thoughts as to how I can get this conversion to happen outside of the class?

In an ideal world I'd change the solr document so it was a child object (well, list of them), but that isn't possible as it's part of a legacy system.

lukens
  • 479
  • 4
  • 10

0 Answers0