use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testFunctionsRTG.
public void testFunctionsRTG() throws Exception {
// if we use RTG (committed or otherwise) functions should behave the same
for (String id : Arrays.asList("42", "99")) {
for (SolrParams p : Arrays.asList(params("fl", "log(val_i),abs(val_i)"), params("fl", "log(val_i)", "fl", "abs(val_i)"))) {
SolrDocument doc = getRandClient(random()).getById(id, p);
String msg = id + "," + p + " => " + doc;
assertEquals(msg, 2, doc.size());
assertTrue(msg, doc.getFieldValue("log(val_i)") instanceof Double);
assertTrue(msg, doc.getFieldValue("abs(val_i)") instanceof Float);
// true for both these specific docs
assertEquals(msg, 0.0D, doc.getFieldValue("log(val_i)"));
assertEquals(msg, 1.0F, doc.getFieldValue("abs(val_i)"));
}
}
}
use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testAllRealFieldsRTG.
public void testAllRealFieldsRTG() throws Exception {
// shouldn't matter if we use RTG (committed or otherwise)
for (String fl : TestPseudoReturnFields.ALL_REAL_FIELDS) {
for (int i : Arrays.asList(42, 43, 44, 45, 46, 99)) {
SolrDocument doc = getRandClient(random()).getById("" + i, params("fl", fl));
assertEquals(fl + " => " + doc, 4, doc.size());
assertTrue(fl + " => " + doc, doc.getFieldValue("id") instanceof String);
assertTrue(fl + " => " + doc, doc.getFieldValue("val_i") instanceof Integer);
assertTrue(fl + " => " + doc, doc.getFieldValue("subject") instanceof String);
// TODO: val_ss: List<String>
assertTrue(fl + " => " + doc, doc.getFieldValue("ssto") instanceof String);
}
}
}
use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testScoreAndAllRealFieldsRTG.
public void testScoreAndAllRealFieldsRTG() throws Exception {
// also shouldn't matter if we use RTG (committed or otherwise) .. score should be ignored
for (String fl : TestPseudoReturnFields.SCORE_AND_REAL_FIELDS) {
for (int i : Arrays.asList(42, 43, 44, 45, 46, 99)) {
SolrDocument doc = getRandClient(random()).getById("" + i, params("fl", fl));
assertEquals(fl + " => " + doc, 4, doc.size());
assertTrue(fl + " => " + doc, doc.getFieldValue("id") instanceof String);
assertTrue(fl + " => " + doc, doc.getFieldValue("val_i") instanceof Integer);
assertTrue(fl + " => " + doc, doc.getFieldValue("subject") instanceof String);
// TODO: val_ss: List<String>
assertTrue(fl + " => " + doc, doc.getFieldValue("ssto") instanceof String);
}
}
}
use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testFilterAndOneRealFieldRTG.
public void testFilterAndOneRealFieldRTG() throws Exception {
SolrParams params = params("fl", "id,val_i", "fq", "{!field f='subject' v=$my_var}", "my_var", "uncommitted");
SolrDocumentList docs = getRandClient(random()).getById(Arrays.asList("42", "99"), params);
final String msg = params + " => " + docs;
assertEquals(msg, 1, docs.size());
assertEquals(msg, 1, docs.getNumFound());
SolrDocument doc = docs.get(0);
assertEquals(msg, 2, doc.size());
assertEquals(msg, "99", doc.getFieldValue("id"));
assertEquals(msg, 1, doc.getFieldValue("val_i"));
}
use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testScoreAndAllRealFields.
public void testScoreAndAllRealFields() throws Exception {
for (String fl : TestPseudoReturnFields.SCORE_AND_REAL_FIELDS) {
SolrDocumentList docs = assertSearch(params("q", "*:*", "rows", "10", "fl", fl));
// shouldn't matter what doc we pick...
for (SolrDocument doc : docs) {
assertEquals(fl + " => " + doc, 5, doc.size());
assertTrue(fl + " => " + doc, doc.getFieldValue("id") instanceof String);
assertTrue(fl + " => " + doc, doc.getFieldValue("score") instanceof Float);
assertTrue(fl + " => " + doc, doc.getFieldValue("val_i") instanceof Integer);
assertTrue(fl + " => " + doc, doc.getFieldValue("subject") instanceof String);
// TODO: val_ss: List<String>
assertTrue(fl + " => " + doc, doc.getFieldValue("ssto") instanceof String);
}
}
}
Aggregations