You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Avlesh Singh (JIRA)" <ji...@apache.org> on 2009/04/25 23:39:30 UTC
[jira] Updated: (SOLR-1129) SolrJ cannot bind dynamic fields to
beans
[ https://issues.apache.org/jira/browse/SOLR-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Avlesh Singh updated SOLR-1129:
-------------------------------
Attachment: SOLR-1129.patch
Adding a patch for this enhancement.
Existing test cases pass. I'll add new test cases in {{TestDocumentObjectBinder}} shortly.
This is the approach I took.
# Dynamic fields can be annotated in the following manner
{code:java}
@Field("*_random")
public Map<String, Integer> random;
@Field("supplier_*")
public Map<String, String[]> suppliers;
@Field("oem_*")
public Map<String, List<String>> oem;
{code}
# Based on the {{value type}} of this {{Map}}, I populate all matching fields in the response with their corresponding value(s).
# I added one more clause to the {{DocField}}'s {{storeType}} method to take care of fields of type {{Map}}. Using {{getActualTypeArguments}} for this {{ParameterizedType}} value, I populate the existing properties in the {{DocField}} viz {{name, field, type, isArray, isList}} etc.
# I added a private method, {{getFieldValueByFieldName(SolrDocument sdoc, String fieldName)}} in the {{DocField}} class, which is now being called by the {{inject}} method for all fields. For regular index fields, the method behavior has not changed. However, for a dynamic field (as annotated by the client), this method prepares a {{Map}} of matching fieldNames and their corresponding value(s). This in turn is used by the {{inject}} method to call the client bean's corresponding setter method.
Please note that this fix is for version 1.3.
Cheers
Avlesh
> SolrJ cannot bind dynamic fields to beans
> -----------------------------------------
>
> Key: SOLR-1129
> URL: https://issues.apache.org/jira/browse/SOLR-1129
> Project: Solr
> Issue Type: Improvement
> Components: clients - java
> Affects Versions: 1.3
> Reporter: Noble Paul
> Attachments: SOLR-1129.patch
>
>
> SolrJ does not support binding of dynamic fields to bean fields
> The field declaration could be as follows
> {code:java}
> @Field("*_s")
> public String anyString;
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.