SOLR-2545: fix ExternalFileField / FileFloatSource so it can properly parse key=val pairs when the key contains an '=' char

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1147284 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2011-07-15 19:14:01 +00:00
parent c899fe0dc0
commit 2811c79bdb
4 changed files with 21 additions and 1 deletions

View File

@ -375,6 +375,11 @@ Bug Fixes
* SOLR-2642: Fixed sorting by function when using grouping. (Thomas Heigl, Martijn van Groningen)
* SOLR-2545: ExternalFileField file parsing would fail if any key
contained an "=" character. It now only looks for the last "=" delimiter
prior to the float value.
(Markus Jelsma, hossman)
Other Changes
----------------------

View File

@ -248,7 +248,7 @@ public class FileFloatSource extends ValueSource {
// final Bits liveDocs = MultiFields.getLiveDocs(reader);
for (String line; (line=r.readLine())!=null;) {
int delimIndex = line.indexOf(delimiter);
int delimIndex = line.lastIndexOf(delimiter);
if (delimIndex < 0) continue;
int endIndex = line.length();

View File

@ -239,6 +239,8 @@
<fieldType name="file" keyField="id" defVal="1" stored="false" indexed="false" class="solr.ExternalFileField" valType="float"/>
<fieldType name="sfile" keyField="sfile_s" defVal="1" stored="false" indexed="false" class="solr.ExternalFileField" valType="float"/>
<fieldType name="tint" class="solr.TrieIntField" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="tfloat" class="solr.TrieFloatField" omitNorms="true" positionIncrementGap="0"/>
@ -340,6 +342,7 @@ valued. -->
<dynamicField name="*_ws" type="text_ws" indexed="true" stored="true"/>
<dynamicField name="*_extf" type="file"/>
<dynamicField name="*_extfs" type="sfile"/>
<dynamicField name="*_random" type="random" />

View File

@ -283,6 +283,18 @@ public class TestFunctionQuery extends SolrTestCaseJ4 {
purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
}
@Test
public void testExternalFileFieldStringKeys() throws Exception {
final String extField = "foo_extfs";
final String keyField = "sfile_s";
assertU(adoc("id", "991", keyField, "AAA=AAA"));
assertU(adoc("id", "992", keyField, "BBB"));
assertU(adoc("id", "993", keyField, "CCC=CCC"));
assertU(commit());
makeExternalFile(extField, "AAA=AAA=543210\nBBB=-8\nCCC=CCC=250","UTF-8");
singleTest(extField,"\0",991,543210,992,-8,993,250);
}
@Test
public void testGeneral() throws Exception {
clearIndex();