use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method assertSearchOneDoc.
/**
* Given a set of query params, executes as a Query against a random SolrClient and
* asserts that exactly one document is returned
*/
public static SolrDocument assertSearchOneDoc(SolrParams p) throws Exception {
SolrDocumentList docs = assertSearch(p);
assertEquals("does not match exactly one doc: " + p.toString() + " => " + docs.toString(), 1, docs.getNumFound());
assertEquals("does not contain exactly one doc: " + p.toString() + " => " + docs.toString(), 1, docs.size());
return docs.get(0);
}
use of org.apache.solr.common.SolrDocumentList 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);
}
}
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testGlobs.
public void testGlobs() throws Exception {
SolrDocumentList docs = assertSearch(params("q", "*:*", "rows", "10", "fl", "val_*"));
assertEquals(5, docs.getNumFound());
// shouldn't matter what doc we pick...
for (SolrDocument doc : docs) {
assertEquals(doc.toString(), 1, doc.size());
assertTrue(doc.toString(), doc.getFieldValue("val_i") instanceof Integer);
}
for (SolrParams p : Arrays.asList(params("q", "*:*", "rows", "10", "fl", "val_*,subj*,ss*"), params("q", "*:*", "rows", "10", "fl", "val_*", "fl", "subj*,ss*"), params("q", "*:*", "rows", "10", "fl", "val_*", "fl", "subj*", "fl", "ss*"))) {
docs = assertSearch(p);
// shouldn't matter what doc we pick...
for (SolrDocument doc : docs) {
String msg = p + " => " + doc;
assertEquals(msg, 3, doc.size());
assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
assertTrue(msg, doc.getFieldValue("subject") instanceof String);
// TODO: val_ss: List<String>
assertTrue(msg, doc.getFieldValue("ssto") instanceof String);
assertEquals(msg, "X", doc.getFieldValue("ssto"));
}
}
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testGlobsAndScore.
public void testGlobsAndScore() throws Exception {
SolrDocumentList docs = assertSearch(params("q", "*:*", "rows", "10", "fl", "val_*,score"));
assertEquals(5, docs.getNumFound());
// shouldn't matter what doc we pick...
for (SolrDocument doc : docs) {
assertEquals(doc.toString(), 2, doc.size());
assertTrue(doc.toString(), doc.getFieldValue("val_i") instanceof Integer);
assertTrue(doc.toString(), doc.getFieldValue("score") instanceof Float);
}
for (SolrParams p : Arrays.asList(params("q", "*:*", "rows", "10", "fl", "val_*,subj*,score"), params("q", "*:*", "rows", "10", "fl", "val_*", "fl", "subj*", "fl", "score"), params("q", "*:*", "rows", "10", "fl", "val_*", "fl", "subj*,score"))) {
docs = assertSearch(p);
assertEquals(p + " => " + docs, 5, docs.getNumFound());
// shouldn't matter what doc we pick...
for (SolrDocument doc : docs) {
String msg = p + " => " + doc;
assertEquals(msg, 3, doc.size());
assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
assertTrue(msg, doc.getFieldValue("subject") instanceof String);
assertTrue(msg, doc.getFieldValue("score") instanceof Float);
}
}
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testFunctionsAndExplicit.
public void testFunctionsAndExplicit() throws Exception {
for (SolrParams p : Arrays.asList(params("q", "*:*", "rows", "1", "fl", "log(val_i),val_i"), params("q", "*:*", "rows", "1", "fl", "log(val_i)", "fl", "val_i"))) {
SolrDocumentList docs = assertSearch(p);
assertEquals(p + " => " + docs, 5, docs.getNumFound());
// doesn't really matter which one
SolrDocument doc = docs.get(0);
assertEquals(p + " => " + doc, 2, doc.size());
assertTrue(p + " => " + doc, doc.getFieldValue("log(val_i)") instanceof Double);
assertTrue(p + " => " + doc, doc.getFieldValue("val_i") instanceof Integer);
}
}
Aggregations