Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Fix for SOLR-2987 (numeric keys in external file field stopped processing the rest of the file)

Erick Erickson7de1e259f18e
diff --git a/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java b/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
index 1333254e975..f8361a4b1ec 100755
--- a/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
+++ b/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
@@ -255,10 +255,9 @@ public class FileFloatSource extends ValueSource {
String key = line.substring(0, delimIndex);
String val = line.substring(delimIndex+1, endIndex);
- idType.readableToIndexed(key, internalKey);
-
float fval;
try {
+ idType.readableToIndexed(key, internalKey);
fval=Float.parseFloat(val);
} catch (Exception e) {
if (++otherErrors<=10) {
diff --git a/solr/core/src/test-files/solr/conf/schema11.xml b/solr/core/src/test-files/solr/conf/schema11.xml
index c4c932b8c5b..6d5fd1adc5c 100755
--- a/solr/core/src/test-files/solr/conf/schema11.xml
+++ b/solr/core/src/test-files/solr/conf/schema11.xml
@@ -273,7 +273,7 @@ valued. -->
stored="false" indexed="true"
class="solr.ExternalFileField" valType="float"/>
- <fieldType name="eff_tfloat" keyField="id" defVal="0"
+ <fieldType name="eff_tfloat" keyField="eff_ti" defVal="0"
stored="false" indexed="true"
class="solr.ExternalFileField" valType="tfloat"/>
@@ -320,6 +320,8 @@ valued. -->
<field name="signatureField" type="string" indexed="true" stored="false"/>
+ <field name="eff_trie" type="eff_tfloat" />
+
<!-- Dynamic field definitions. If a field name is not found, dynamicFields
will be used if the name matches any of the patterns.
RESTRICTION: the glob-like pattern in the name attribute must have
diff --git a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
index 41cb7a1120c..748c1faab34 100755
--- a/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
+++ b/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
@@ -295,6 +295,18 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
singleTest(extField,"\0",991,543210,992,-8,993,250);
}
+ @Test
+ public void testExternalFileFieldNumericKey() throws Exception {
+ final String extField = "eff_trie";
+ final String keyField = "eff_ti";
+ assertU(adoc("id", "991", keyField, "91"));
+ assertU(adoc("id", "992", keyField, "92"));
+ assertU(adoc("id", "993", keyField, "93"));
+ assertU(commit());
+ makeExternalFile(extField, "91=543210\n92=-8\n93=250\n=67","UTF-8");
+ singleTest(extField,"\0",991,543210,992,-8,993,250);
+ }
+
@Test
public void testGeneral() throws Exception {
clearIndex();