Skip to content

Commit

Permalink
[SOLR-12697] add tests for parsing different sortedDocValues, add ent…
Browse files Browse the repository at this point in the history
…ry to CHANGES.txt
  • Loading branch information
tomglk committed May 19, 2021
1 parent b105627 commit e07c432
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ New Features

* SOLR-15397: Expose zookeeper status in the Prometheus exporter (janhoy)

* SOLR-12697: Add pure DocValues support to FieldValueFeature (Tom Gilke, Christine Poerschke)

Improvements
---------------------
* SOLR-15081: Metrics for a core: add SolrCloud "isLeader" and "replicaState". (David Smiley)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,40 @@ public void testParamsToMap() throws Exception {
doTestParamsToMap(FieldValueFeature.class.getName(), params);
}

@Test
public void testThatStringValuesAreCorrectlyParsed() throws Exception {
final String[][] inputsAndTests = {
new String[]{"T", "/response/docs/[0]/=={'[fv]':'" +
FeatureLoggerTestUtils.toFeatureVector("dvStrNumField", "1.0")+"'}"},
new String[]{"F", "/response/docs/[0]/=={'[fv]':'" +
FeatureLoggerTestUtils.toFeatureVector("dvStrNumField", "0.0")+"'}"},
new String[]{"-7324.427", "/response/docs/[0]/=={'[fv]':'" +
FeatureLoggerTestUtils.toFeatureVector("dvStrNumField", "-7324.427")+"'}"},
new String[]{"532", "/response/docs/[0]/=={'[fv]':'" +
FeatureLoggerTestUtils.toFeatureVector("dvStrNumField", "532.0")+"'}"},
new String[]{"notanumber", "/error/msg/=='org.apache.solr.ltr.feature.FeatureException: " +
"Cannot parse value notanumber of field dvStrNumField to float.'"}
};

final String fstore = "testThatStringValuesAreCorrectlyParsed";
loadFeature("dvStrNumField", FieldValueFeature.class.getName(), fstore,
"{\"field\":\"" + "dvStrNumField" + "\"}");
loadModel("dvStrNumField-model", LinearModel.class.getName(),
new String[]{"dvStrNumField"}, fstore, "{\"weights\":{\"" + "dvStrNumField" + "\":1.0}}");

for (String[] inputAndTest : inputsAndTests) {
assertU(adoc("id", "21", "dvStrNumField", inputAndTest[0]));
assertU(commit());

SolrQuery query = new SolrQuery();
query.setQuery("id:21");
query.add("rq", "{!ltr model=" + "dvStrNumField" + "-model reRankDocs=4}");
query.add("fl", "[fv]");

assertJQ("/query" + query.toQueryString(), inputAndTest[1]);
}
}

/**
* This class is used to track which specific FieldValueFeature is used so that we can test, whether the
* fallback mechanism works correctly.
Expand Down

0 comments on commit e07c432

Please sign in to comment.