use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestBinaryResponseWriter method testUUID.
/**
* Tests known types implementation by asserting correct encoding/decoding of UUIDField
*/
public void testUUID() throws Exception {
String s = UUID.randomUUID().toString().toLowerCase(Locale.ROOT);
assertU(adoc("id", "101", "uuid", s));
assertU(commit());
LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*");
SolrQueryResponse rsp = h.queryAndResponse(req.getParams().get(CommonParams.QT), req);
BinaryQueryResponseWriter writer = (BinaryQueryResponseWriter) h.getCore().getQueryResponseWriter("javabin");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writer.write(baos, req, rsp);
NamedList res = (NamedList) new JavaBinCodec().unmarshal(new ByteArrayInputStream(baos.toByteArray()));
SolrDocumentList docs = (SolrDocumentList) res.get("response");
for (Object doc : docs) {
SolrDocument document = (SolrDocument) doc;
assertEquals("Returned object must be a string", "java.lang.String", document.getFieldValue("uuid").getClass().getName());
assertEquals("Wrong UUID string returned", s, document.getFieldValue("uuid"));
}
req.close();
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestJavabinTupleStreamParser method testSolrDocumentList.
public void testSolrDocumentList() throws IOException {
SolrQueryResponse response = new SolrQueryResponse();
SolrDocumentList l = constructSolrDocList(response);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new JavaBinCodec().marshal(response.getValues(), baos);
byte[] bytes = serialize(response.getValues());
Object o = new JavaBinCodec().unmarshal(new ByteArrayInputStream(bytes));
List list = new ArrayList<>();
Map m = null;
JavabinTupleStreamParser parser = new JavabinTupleStreamParser(new ByteArrayInputStream(bytes), false);
while ((m = parser.next()) != null) {
list.add(m);
}
assertEquals(l.size(), list.size());
for (int i = 0; i < list.size(); i++) {
compareSolrDocument(l.get(i), new SolrDocument((Map<String, Object>) list.get(i)));
}
}
use of org.apache.solr.common.SolrDocumentList in project jackrabbit-oak by apache.
the class LMSEstimatorTest method testMultipleUpdates.
@Test
public void testMultipleUpdates() throws Exception {
LMSEstimator lmsEstimator = new LMSEstimator();
Filter filter = mock(Filter.class);
FullTextExpression fte = new FullTextTerm("foo", "bar", false, false, "");
when(filter.getFullTextConstraint()).thenReturn(fte);
SolrDocumentList docs = new SolrDocumentList();
lmsEstimator.update(filter, docs);
long actualCount = 10;
docs.setNumFound(actualCount);
long estimate = lmsEstimator.estimate(filter);
long diff = actualCount - estimate;
// update causes weights adjustment
lmsEstimator.update(filter, docs);
long estimate2 = lmsEstimator.estimate(filter);
long diff2 = actualCount - estimate2;
// new estimate is more accurate than previous one
assertTrue(diff2 < diff);
// update doesn't cause weight adjustments therefore estimates stays unchanged
lmsEstimator.update(filter, docs);
long estimate3 = lmsEstimator.estimate(filter);
assertEquals(estimate3, estimate2);
}
use of org.apache.solr.common.SolrDocumentList in project jackrabbit-oak by apache.
the class LMSEstimatorTest method testUpdate.
@Test
public void testUpdate() throws Exception {
LMSEstimator lmsEstimator = new LMSEstimator();
Filter filter = mock(Filter.class);
SolrDocumentList docs = mock(SolrDocumentList.class);
lmsEstimator.update(filter, docs);
}
use of org.apache.solr.common.SolrDocumentList in project play-cookbook by spinscale.
the class SolrSearchTest method simpleUserTest.
@Test
public void simpleUserTest() throws Exception {
SolrQuery query = new SolrQuery();
query.setQuery("name:alex");
QueryResponse rp = server.query(query);
SolrDocumentList results = rp.getResults();
assertEquals(1, results.size());
assertEquals("alex", results.get(0).getFieldValue("name"));
User u = User.find("byName", "alex").first();
assertEquals(u.getClass().getName() + ":" + u.id.toString(), results.get(0).getFieldValue("id"));
}
Aggregations