lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Rowe (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SOLR-3251) dynamically add fields to schema
Date Wed, 17 Apr 2013 16:23:16 GMT

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

Steve Rowe commented on SOLR-3251:
----------------------------------

{quote}
{code:java}
Index: solr/core/src/java/org/apache/solr/schema/SchemaField.java
   /** Declared field property overrides */
-  Map<String,String> args = Collections.emptyMap();
+  Map<String,?> args = Collections.emptyMap();

-  static SchemaField create(String name, FieldType ft, Map<String,String> props) {
+  static SchemaField create(String name, FieldType ft, Map<String,?> props) {
{code}
Why are we losing type safety here? I'm now unclear on what can be in this properties map...
{quote}

This change was in Yonik's original patch on this issue and I kept it in.  If you look at
his patch, he uses this to carry Booleans in the props map:

{code:java}
Index: core/src/java/org/apache/solr/schema/FieldProperties.java
===================================================================
--- core/src/java/org/apache/solr/schema/FieldProperties.java	(revision 1300409)
+++ core/src/java/org/apache/solr/schema/FieldProperties.java	(working copy)
@@ -101,12 +101,13 @@
     return (bitfield & props) == 0;
   }
 
-  static int parseProperties(Map<String,String> properties, boolean which) {
+  static int parseProperties(Map<String,?> properties, boolean which) {
     int props = 0;
-    for (Map.Entry<String, String> entry : properties.entrySet()) {
-      String val = entry.getValue();
+    for (Map.Entry<String, ?> entry : properties.entrySet()) {
+      Object val = entry.getValue();
       if(val == null) continue;
-      if (Boolean.parseBoolean(val) == which) {
+      boolean boolVal = val instanceof Boolean ? (Boolean)val : Boolean.parseBoolean(val.toString());
+      if (boolVal == which) {
         props |= propertyNameToInt(entry.getKey());
       }
     }
{code} 
                
> dynamically add fields to schema
> --------------------------------
>
>                 Key: SOLR-3251
>                 URL: https://issues.apache.org/jira/browse/SOLR-3251
>             Project: Solr
>          Issue Type: New Feature
>            Reporter: Yonik Seeley
>            Assignee: Steve Rowe
>             Fix For: 4.3, 5.0
>
>         Attachments: SOLR-3251.patch, SOLR-3251.patch, SOLR-3251.patch, SOLR-3251.patch,
SOLR-3251.patch, SOLR-3251.patch
>
>
> One related piece of functionality needed for SOLR-3250 is the ability to dynamically
add a field to the schema.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message