[ 
https://issues.apache.org/jira/browse/SOLR-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12504342
 ] 

Ryan McKinley commented on SOLR-193:
------------------------------------

> The basic structure in the new patch looks fine by the way, no real concerns 
> from me once the comments are cleaned up (one question: should SolrDocument 
> implement Map<String,Collection<Object>> ??) 

If the class implements Map, JSTL treats it differently -- for example, 
${doc.fieldNames}  does not call:
 Collection<String> getFieldNames();
it calls: Map.get( "fieldNames" );

this is really annoying!  Essentially any real function you add is hidden 
(unless i'm incompetent in JSTL land...)

This is why I had:

+  ///////////////////////////////////////////////////////////////////
+  // Utility functions to help JSTL (map interface to single field
+  ///////////////////////////////////////////////////////////////////
+
+  public Map<String,Collection<Object>> getValuesMap()
+  {
+    return _fields;
+  }
+  
+  public Map<String,Object> getValueMap() {
+    return new Map<String,Object>() {
+      // The only reason we are implementing map!
+      public Object get(Object key) { 
+        return getFieldValue( (String)key); 
+      }
+
+      // Easily Supported methods
+      public boolean containsKey(Object key) { return _fields.containsKey( key 
); }
+      public Set<String>  keySet()           { return _fields.keySet();  }
+      public int          size()             { return _fields.size();    }
+      public boolean      isEmpty()          { return _fields.isEmpty(); }
+
+      // Unsupported operations.  These are not necessary for JSTL
+      public void clear() { throw new UnsupportedOperationException(); }
+      public boolean containsValue(Object value) {throw new 
UnsupportedOperationException();}
+      public Set<java.util.Map.Entry<String, Object>> entrySet() {throw new 
UnsupportedOperationException();}
+      public Object put(String key, Object value) {throw new 
UnsupportedOperationException();}
+      public void putAll(Map<? extends String, ? extends Object> t) {throw new 
UnsupportedOperationException();}
+      public Object remove(Object key) {throw new 
UnsupportedOperationException();}
+      public Collection<Object> values() {throw new 
UnsupportedOperationException();}
+    };
+  }


I would still like to include these in the API.




> General SolrDocument interface to manage field values.
> ------------------------------------------------------
>
>                 Key: SOLR-193
>                 URL: https://issues.apache.org/jira/browse/SOLR-193
>             Project: Solr
>          Issue Type: New Feature
>            Reporter: Ryan McKinley
>            Assignee: Ryan McKinley
>         Attachments: SOLR-193-SimpleSolrDocument.patch, 
> SOLR-193-SimpleSolrDocument.patch, SOLR-193-SolrDocument.patch, 
> SOLR-193-SolrDocument.patch, SOLR-193-SolrDocument.patch, 
> SOLR-193-SolrDocument.patch, SOLR-193-SolrDocument.patch, 
> SOLR-193-SolrDocument.patch
>
>
> In an effort to make SOLR-139 (the "modify" command) more manageable, i 
> extracted out a large chunk.  This patch adds a general SolrDocument 
> interface and includes a concrete implementation (SimpleSolrDoc)
> SOLR-139 needs some way to transport document values independent of the 
> lucene Document.  This is required for the INCREMENT command and useful for 
> modifying documents.  SolrDocument is also generally useful for SOLR-20
> - - - - - -
> The one (potentially) controversial part is that I added a function to 
> FieldType:
>  public Object toExternalValue(Fieldable f);
> This asks each field type to convert its Fieldable into its real type, for 
> example IntField.java has:
>  public Integer toExternalValue(Fieldable f) {
>    return Integer.valueOf( toExternal(f) );
>  }
> By default, it returns a string value.  If this addition is too much, there 
> are other (less clean) ways to handle the INCREMENT command.  My real 
> motivation for this addition is that it makes it possible to implement an 
> embeddable SOLR-20 client that does not need an HTTP connection. 
> - - - -
> The SimpleSolrDoc implementation was written for SOLR-20.  It needs to play 
> nice with EL, so it implements a few extra map function that may not seem 
> necessary:
>  ${doc.values['name']]} gets a collection
>  ${doc.valueMap['name']]} gets a single value for the field
> - - - -
> The tests cover all "toExternalValue" changes in schema.*  
> SimpleSolrDoc and DocumentBuilder have 100% test coverage.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to