[ https://issues.apache.org/jira/browse/SOLR-1357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12784449#action_12784449 ]
Lars Grote commented on SOLR-1357: ---------------------------------- Hey Noble, I have a question ... again. The question is somehow related to the the issue [SOLR-1129|https://issues.apache.org/jira/browse/SOLR-1129]. I copied the loop of Jean, and started implementing the unit test and came across a problem. The code below is copied from the existing unittest. Assume you have two fields annotated like this: {code:title=TestDocumentObjectBinder .java} @Field("supplier_*") Map<String, List<String>> supplier; @Field("supplier_*") public void setAllSuppliers(String[] allSuppliers){ this.allSuppliers = allSuppliers; } {code} In my opinion the second field should be ignored when the bean is converted to the SolrImportDocument (it is not ignored in the current implementation). Otherwise you get in trouble when you try to get the bean out and try to put it back in. So I would ignore all fields that are annotated as a dynamic field, an are not of the type Map when converting a Bean to a SolrInputDocument. When converting a SolrDocument to a Bean, it should be like it is now (not ignored, the field "allSuppliers" is injected with all Suppliers). What do you think? Regards, Lars > SolrInputDocument cannot process dynamic fields > ----------------------------------------------- > > Key: SOLR-1357 > URL: https://issues.apache.org/jira/browse/SOLR-1357 > Project: Solr > Issue Type: Improvement > Components: clients - java > Reporter: Avlesh Singh > Assignee: Noble Paul > Attachments: SOLR-1357.patch > > > Adding data via {{SolrInputDocument}} is normally done by calling the > {{addField}} method with a field name, field value and an optional boost. In > case of dynamic fields, if field names are known upfront, then caller of this > method just passes in the right name and it automatically works. > This does not go well with users who use {...@interface Field}} annotations > for automatic binding. > As of SOLR-1129, users can annotate {{Map<String, String> propertyName}} with > {...@field ("field_*")}} kind of annotations to bind dynamic field data to. > {{SolrInputDocument}} should exhibit the same behavior. The field {{value}} > currently supported are - primitive, array, collection or an instance of > Iterable. It can also take {{Map}} as values. If the field, for which > {{addField}} method is called, is of dynamicField type (which can be derived > from the field name), then the keys of the {{Map}}, passed as value, should > be used to "compose" the correct field name. > This should be supported > {code:java} > //This code sample should populate the dynamic fields "brands_Nokia" and > "brands_Samsung" > public class MyBean{ > @Field("brands_*) > Map<String, Integer> brands; > > ... > } > Map<String, String> brands= new HashMap<String, String>(); > brands.put("Nokia", 1000); > brands.put("Samsung", 100); > MyBean myBean = new MyBean(); > myBean.setBrands(brands); > solrServer.addBean(myBean); > {code} > We can think of supporting this too ... > {code:java} > //This code sample should populate the dynamic fields "brands_Nokia" and > "brands_Samsung" > Map<String, String> brands= new HashMap<String, String>(); > brands.put("Nokia", 1000); > brands.put("Samsung", 100); > SolrInputDocument doc = new SolrInputDocument(); > doc.addField("brands_*", brands); > {code} -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.