You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2010/07/01 12:22:49 UTC

svn commit: r959585 - /incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java

Author: kwright
Date: Thu Jul  1 10:22:49 2010
New Revision: 959585

URL: http://svn.apache.org/viewvc?rev=959585&view=rev
Log:
Put an insanity mapping in by default, so we don't get collisions with Solr's declared id field.  This also restores backwards functional compatibility.

Modified:
    incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java

Modified: incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java?rev=959585&r1=959584&r2=959585&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java (original)
+++ incubator/lcf/trunk/modules/connectors/solr/connector/org/apache/lcf/agents/output/solr/HttpPoster.java Thu Jul  1 10:22:49 2010
@@ -69,7 +69,8 @@ public class HttpPoster
 
   private static final String LITERAL = "literal.";
   private static final String NOTHING = "__NOTHING__";
-    
+  private static final String ID_METADATA = "lcf_metadata_id";
+  
   private int buffersize = 32768;  // default buffer size
   double sizeCoefficient = 0.0005;    // 20 ms additional timeout per 2000 bytes, pulled out of my butt
   /** the number of times we should poll for the response */
@@ -975,8 +976,11 @@ public class HttpPoster
                   String newFieldName = (String)sourceTargets.get(fieldName);
                   if (newFieldName == null)
                     newFieldName = fieldName;
-                  if (newFieldName.length() > 0)
-                  {
+		  // Make SURE we can't double up on the id field inadvertantly!
+		  if (newFieldName.length() > 0)
+		  {
+		    if (newFieldName.toLowerCase().equals(idAttributeName.toLowerCase()))
+		      newFieldName = ID_METADATA;
                     Object[] values = document.getField(fieldName);
                     // We only handle strings right now!!!
                     int k = 0;
@@ -1037,8 +1041,10 @@ public class HttpPoster
                   String newFieldName = (String)sourceTargets.get(fieldName);
                   if (newFieldName == null)
                     newFieldName = fieldName;
-                  if (newFieldName.length() > 0)
-                  {
+		  if (newFieldName.length() > 0)
+		  {
+		    if (newFieldName.toLowerCase().equals(idAttributeName.toLowerCase()))
+		      newFieldName = ID_METADATA;
                     Object[] values = document.getField(fieldName);
                     // We only handle strings right now!!!
                     int k = 0;