use of org.apache.solr.common.SolrDocument 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.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testGlobsAndExplicitRTG.
public void testGlobsAndExplicitRTG() throws Exception {
// behavior shouldn't matter if we are committed or uncommitted
for (String id : Arrays.asList("42", "99")) {
SolrDocument doc = getRandClient(random()).getById(id, params("fl", "val_*,id"));
String msg = id + ": fl=val_*,id => " + doc;
assertEquals(msg, 2, doc.size());
assertTrue(msg, doc.getFieldValue("id") instanceof String);
assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
assertEquals(msg, 1, doc.getFieldValue("val_i"));
for (SolrParams p : Arrays.asList(params("fl", "val_*,subj*,id"), params("fl", "val_*", "fl", "subj*", "fl", "id"), params("fl", "val_*", "fl", "subj*,id"))) {
doc = getRandClient(random()).getById(id, p);
msg = id + ": " + p + " => " + doc;
assertEquals(msg, 3, doc.size());
assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
assertEquals(msg, 1, doc.getFieldValue("val_i"));
assertTrue(msg, doc.getFieldValue("subject") instanceof String);
assertTrue(msg, doc.getFieldValue("id") instanceof String);
}
}
}
use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testDocIdAugmenterRTG.
public void testDocIdAugmenterRTG() throws Exception {
// for an uncommitted doc, we should get -1
for (String id : Arrays.asList("42", "99")) {
SolrDocument doc = getRandClient(random()).getById(id, params("fl", "[docid]"));
String msg = id + ": fl=[docid] => " + doc;
assertEquals(msg, 1, doc.size());
assertTrue(msg, doc.getFieldValue("[docid]") instanceof Integer);
assertTrue(msg, -1 <= ((Integer) doc.getFieldValue("[docid]")).intValue());
}
}
use of org.apache.solr.common.SolrDocument in project lucene-solr by apache.
the class TestCloudPseudoReturnFields method testAugmentersGlobsExplicitAndScoreOhMyRTG.
public void testAugmentersGlobsExplicitAndScoreOhMyRTG() throws Exception {
Random random = random();
// NOTE: 'ssto' is the missing one
final List<String> fl = Arrays.asList("id", "[docid]", "[explain]", "score", "val_*", "subj*");
final int iters = atLeast(random, 10);
for (int i = 0; i < iters; i++) {
Collections.shuffle(fl, random);
final SolrParams singleFl = params("fl", StringUtils.join(fl.toArray(), ','));
final ModifiableSolrParams multiFl = params();
for (String item : fl) {
multiFl.add("fl", item);
}
// RTG behavior should be consistent, (committed or otherwise)
for (String id : Arrays.asList("42", "99")) {
for (SolrParams params : Arrays.asList(singleFl, multiFl)) {
SolrDocument doc = getRandClient(random()).getById(id, params);
String msg = id + ": " + params + " => " + doc;
assertEquals(msg, 4, doc.size());
assertTrue(msg, doc.getFieldValue("id") instanceof String);
assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
assertEquals(msg, 1, doc.getFieldValue("val_i"));
assertTrue(msg, doc.getFieldValue("subject") instanceof String);
assertTrue(msg, doc.getFieldValue("[docid]") instanceof Integer);
assertTrue(msg, -1 <= ((Integer) doc.getFieldValue("[docid]")).intValue());
// RTG: [explain] and score should be missing (ignored)
}
}
}
}
use of org.apache.solr.common.SolrDocument 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);
}
}
}
Aggregations