SOLR-11163: Fix contrib/ltr Normalizer persistence after solr core reload or restart.

(Yuki Yano via Christine Poerschke)
This commit is contained in:
Christine Poerschke 2017-08-03 16:07:40 +01:00
parent a381bdbaaa
commit c297180cca
5 changed files with 39 additions and 6 deletions

View File

@ -415,6 +415,9 @@ Bug Fixes
* SOLR-11154: Child documents' return fields now include useDocValuesAsStored fields (Mohammed Sheeri Shaketi Nauage via
Ishan Chattopadhyaya)
* SOLR-11163: Fix contrib/ltr Normalizer persistence after solr core reload or restart.
(Yuki Yano via Christine Poerschke)
Optimizations
----------------------

View File

@ -90,8 +90,8 @@ public class MinMaxNormalizer extends Normalizer {
@Override
public LinkedHashMap<String,Object> paramsToMap() {
final LinkedHashMap<String,Object> params = new LinkedHashMap<>(2, 1.0f);
params.put("min", '"'+Float.toString(min)+'"');
params.put("max", '"'+Float.toString(max)+'"');
params.put("min", Float.toString(min));
params.put("max", Float.toString(max));
return params;
}

View File

@ -82,8 +82,8 @@ public class StandardNormalizer extends Normalizer {
@Override
public LinkedHashMap<String,Object> paramsToMap() {
final LinkedHashMap<String,Object> params = new LinkedHashMap<>(2, 1.0f);
params.put("avg", '"'+Float.toString(avg)+'"');
params.put("std", '"'+Float.toString(std)+'"');
params.put("avg", Float.toString(avg));
params.put("std", Float.toString(std));
return params;
}

View File

@ -40,7 +40,7 @@ public class TestMinMaxNormalizer {
final MinMaxNormalizer mmn = (MinMaxNormalizer)n;
assertEquals(mmn.getMin(), expectedMin, 0.0);
assertEquals(mmn.getMax(), expectedMax, 0.0);
assertEquals("{min=\""+expectedMin+"\", max=\""+expectedMax+"\"}", mmn.paramsToMap().toString());
assertEquals("{min="+expectedMin+", max="+expectedMax+"}", mmn.paramsToMap().toString());
return n;
}
@ -118,4 +118,19 @@ public class TestMinMaxNormalizer {
value = 5;
assertEquals((value - 5f) / (10f - 5f), n.normalize(value), 0.0001);
}
@Test
public void testParamsToMap() {
final MinMaxNormalizer n1 = new MinMaxNormalizer();
n1.setMin(5.0f);
n1.setMax(10.0f);
final Map<String,Object> params = n1.paramsToMap();
final MinMaxNormalizer n2 = (MinMaxNormalizer) Normalizer.getInstance(
new SolrResourceLoader(),
MinMaxNormalizer.class.getName(),
params);
assertEquals(n1.getMin(), n2.getMin(), 1e-6);
assertEquals(n1.getMax(), n2.getMax(), 1e-6);
}
}

View File

@ -40,7 +40,7 @@ public class TestStandardNormalizer {
final StandardNormalizer sn = (StandardNormalizer)n;
assertEquals(sn.getAvg(), expectedAvg, 0.0);
assertEquals(sn.getStd(), expectedStd, 0.0);
assertEquals("{avg=\""+expectedAvg+"\", std=\""+expectedStd+"\"}", sn.paramsToMap().toString());
assertEquals("{avg="+expectedAvg+", std="+expectedStd+"}", sn.paramsToMap().toString());
return n;
}
@ -130,4 +130,19 @@ public class TestStandardNormalizer {
assertEquals((v - 10f) / (1.5f), norm.normalize(v), 0.0001);
}
}
@Test
public void testParamsToMap() {
final StandardNormalizer n1 = new StandardNormalizer();
n1.setAvg(2.0f);
n1.setStd(3.0f);
final Map<String, Object> params = n1.paramsToMap();
final StandardNormalizer n2 = (StandardNormalizer) Normalizer.getInstance(
new SolrResourceLoader(),
StandardNormalizer.class.getName(),
params);
assertEquals(n1.getAvg(), n2.getAvg(), 1e-6);
assertEquals(n1.getStd(), n2.getStd(), 1e-6);
}
}