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 Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com> on 2009/12/11 10:29:37 UTC

Re: svn commit: r886127 - in /lucene/solr/trunk/src: solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java

fixed. Thanks Hoss

On Fri, Dec 11, 2009 at 7:01 AM, Chris Hostetter
<ho...@fucit.org> wrote:
>
> Noble:
> 1) you *have* to include a CHANGES.txt entry for every non-trivial commit
> ... if it has a Jira issue, there better be a CHANGES.txt entry, and the
> CHANGES.txt entry really needs to be in the same atomic commit as the rest
> of the changes, not a follow up commit, so code changes can be correlated
> to why the change was made.
>
> 2) CHANGES.txt entries must cite teh person who contributed the patch.
>
> 3) you have to be careful to cite the correct Jira issue when making
> commits -- this commit doesn't seem to have anything to do with SOLR-1516,
> i'm pretty sure it was for SOLR-1357
>
> ...with out all three of these things, it's nearly impossible to audit
> changes later and understand what they were, and who they came from.
>
>
> : Date: Wed, 02 Dec 2009 11:57:17 -0000
> : From: noble@apache.org
> : Reply-To: solr-dev@lucene.apache.org
> : To: solr-commits@lucene.apache.org
> : Subject: svn commit: r886127 - in /lucene/solr/trunk/src:
> :     solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
> :     test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java
> :
> : Author: noble
> : Date: Wed Dec  2 11:57:15 2009
> : New Revision: 886127
> :
> : URL: http://svn.apache.org/viewvc?rev=886127&view=rev
> : Log:
> : SOLR-1516 SolrInputDocument cannot process dynamic fields
> :
> : Modified:
> :     lucene/solr/trunk/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
> :     lucene/solr/trunk/src/test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java
> :
> : Modified: lucene/solr/trunk/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java?rev=886127&r1=886126&r2=886127&view=diff
> : ==============================================================================
> : --- lucene/solr/trunk/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java (original)
> : +++ lucene/solr/trunk/src/solrj/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java Wed Dec  2 11:57:15 2009
> : @@ -76,9 +76,19 @@
> :      }
> :
> :      SolrInputDocument doc = new SolrInputDocument();
> : -    for( DocField field : fields ) {
> : -      doc.setField( field.name, field.get( obj ), 1.0f );
> : -    }
> : +     for (DocField field : fields) {
> : +             if (field.dynamicFieldNamePatternMatcher != null
> : +                             && field.get(obj) != null && field.isContainedInMap) {
> : +                     Map<String, Object> mapValue = (HashMap<String, Object>) field
> : +                                     .get(obj);
> : +
> : +                     for (Map.Entry<String, Object> e : mapValue.entrySet()) {
> : +                             doc.setField( e.getKey(), e.getValue(), 1.0f);
> : +                     }
> : +             } else {
> : +                     doc.setField(field.name, field.get(obj), 1.0f);
> : +             }
> : +     }
> :      return doc;
> :    }
> :
> :
> : Modified: lucene/solr/trunk/src/test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java?rev=886127&r1=886126&r2=886127&view=diff
> : ==============================================================================
> : --- lucene/solr/trunk/src/test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java (original)
> : +++ lucene/solr/trunk/src/test/org/apache/solr/client/solrj/beans/TestDocumentObjectBinder.java Wed Dec  2 11:57:15 2009
> : @@ -25,12 +25,14 @@
> :  import org.apache.solr.common.SolrInputDocument;
> :  import org.apache.solr.common.SolrInputField;
> :  import org.apache.solr.common.SolrDocument;
> : +import org.apache.solr.common.util.Hash;
> :  import org.apache.solr.common.util.NamedList;
> :  import org.junit.Assert;
> :
> :  import java.io.StringReader;
> :  import java.util.Arrays;
> :  import java.util.Date;
> : +import java.util.HashMap;
> :  import java.util.List;
> :  import java.util.Map;
> :
> : @@ -100,6 +102,15 @@
> :      item.inStock = false;
> :      item.categories =  new String[] { "aaa", "bbb", "ccc" };
> :      item.features = Arrays.asList( item.categories );
> : +    List<String> supA =  Arrays.asList(  new String[] { "supA1", "supA2", "supA3" } );
> : +    List<String> supB =  Arrays.asList(  new String[] { "supB1", "supB2", "supB3"});
> : +    item.supplier = new HashMap<String, List<String>>();
> : +    item.supplier.put("supplier_supA", supA);
> : +    item.supplier.put("supplier_supB", supB);
> : +
> : +    item.supplier_simple = new HashMap<String, String>();
> : +    item.supplier_simple.put("sup_simple_supA", "supA_val");
> : +    item.supplier_simple.put("sup_simple_supB", "supB_val");
> :
> :      DocumentObjectBinder binder = new DocumentObjectBinder();
> :      SolrInputDocument doc = binder.toSolrInputDocument( item );
> : @@ -113,10 +124,38 @@
> :      Assert.assertEquals( item.inStock, out.inStock );
> :      Assert.assertEquals( item.categories.length, out.categories.length );
> :      Assert.assertEquals( item.features, out.features );
> : +    Assert.assertEquals( supA,out.supplier.get("supplier_supA"));
> : +    Assert.assertEquals( supB, out.supplier.get("supplier_supB"));
> : +    Assert.assertEquals( item.supplier_simple.get("sup_simple_supB"), out.supplier_simple.get("sup_simple_supB"));
> : +
> :      Assert.assertEquals( item.id, singleOut.id );
> :      Assert.assertEquals( item.inStock, singleOut.inStock );
> :      Assert.assertEquals( item.categories.length, singleOut.categories.length );
> :      Assert.assertEquals( item.features, singleOut.features );
> : +    Assert.assertEquals( supA, singleOut.supplier.get("supplier_supA"));
> : +    Assert.assertEquals( supB, singleOut.supplier.get("supplier_supB"));
> : +    Assert.assertEquals( item.supplier_simple.get("sup_simple_supB"), out.supplier_simple.get("sup_simple_supB"));
> : +
> : +//    put back "out" as Bean, to see if both ways work as you would expect
> : +//    but the Field that "allSuppliers" need to be cleared, as it is just for
> : +//    retrieving data, not to post data
> : +    out.allSuppliers = null;
> : +    SolrInputDocument doc1 = binder.toSolrInputDocument( out );
> : +
> : +    SolrDocumentList docs1 = new SolrDocumentList();
> : +    docs1.add( ClientUtils.toSolrDocument(doc1) );
> : +    Item out1 = binder.getBeans( Item.class, docs1 ).get( 0 );
> : +
> : +    Assert.assertEquals( item.id, out1.id );
> : +    Assert.assertEquals( item.inStock, out1.inStock );
> : +    Assert.assertEquals( item.categories.length, out1.categories.length );
> : +    Assert.assertEquals( item.features, out1.features );
> : +
> : +    Assert.assertEquals( item.supplier_simple.get("sup_simple_supB"), out1.supplier_simple.get("sup_simple_supB"));
> : +
> : +    Assert.assertEquals( supA,out1.supplier.get("supplier_supA"));
> : +    Assert.assertEquals( supB, out1.supplier.get("supplier_supB"));
> : +
> :    }
> :
> :    public static class Item {
> : @@ -139,6 +178,9 @@
> :
> :      @Field("supplier_*")
> :      Map<String, List<String>> supplier;
> : +
> : +    @Field("sup_simple_*")
> : +    Map<String, String> supplier_simple;
> :
> :      private String[] allSuppliers;
> :
> :
> :
>
>
>
> -Hoss
>
>



-- 
-----------------------------------------------------
Noble Paul | Systems Architect| AOL | http://aol.com