use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class TestLogWatcher method testLog4jWatcher.
@Test
public void testLog4jWatcher() {
LogWatcher watcher = LogWatcher.newRegisteredLogWatcher(config, null);
assertEquals(watcher.getLastEvent(), -1);
log.warn("This is a test message");
assertTrue(watcher.getLastEvent() > -1);
SolrDocumentList events = watcher.getHistory(-1, new AtomicBoolean());
assertEquals(events.size(), 1);
SolrDocument event = events.get(0);
assertEquals(event.get("logger"), "org.apache.solr.logging.TestLogWatcher");
assertEquals(event.get("message"), "This is a test message");
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class CloudMLTQParserTest method testMultipleFields.
@Test
public void testMultipleFields() throws Exception {
QueryResponse queryResponse = cluster.getSolrClient().query(COLLECTION, new SolrQuery("{!mlt qf=lowerfilt_u,lowerfilt1_u mindf=0 mintf=1}26"));
SolrDocumentList solrDocuments = queryResponse.getResults();
int[] expectedIds = new int[] { 3, 29, 27, 28 };
int[] actualIds = new int[solrDocuments.size()];
int i = 0;
for (SolrDocument solrDocument : solrDocuments) {
actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
assertArrayEquals(expectedIds, actualIds);
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class CloudMLTQParserTest method testUnstoredAndUnanalyzedFieldsAreIgnored.
@Test
public void testUnstoredAndUnanalyzedFieldsAreIgnored() throws Exception {
// Assert that {!mlt}id does not throw an exception i.e. implicitly, only fields that are stored + have explicit
// analyzer are used for MLT Query construction.
QueryResponse queryResponse = cluster.getSolrClient().query(COLLECTION, new SolrQuery("{!mlt}20"));
SolrDocumentList solrDocuments = queryResponse.getResults();
int[] actualIds = new int[solrDocuments.size()];
int[] expectedIds = new int[] { 13, 14, 15, 16, 22, 24, 32, 18, 19, 21 };
int i = 0;
StringBuilder sb = new StringBuilder();
for (SolrDocument solrDocument : solrDocuments) {
actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
sb.append(actualIds[i - 1]).append(", ");
}
assertArrayEquals(expectedIds, actualIds);
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class CloudMLTQParserTest method testMLTQParser.
@Test
public void testMLTQParser() throws Exception {
QueryResponse queryResponse = cluster.getSolrClient().query(COLLECTION, new SolrQuery("{!mlt qf=lowerfilt_u}17").setShowDebugInfo(true));
SolrDocumentList solrDocuments = queryResponse.getResults();
int[] expectedIds = new int[] { 7, 9, 13, 14, 15, 16, 20, 22, 24, 32 };
int[] actualIds = new int[10];
int i = 0;
for (SolrDocument solrDocument : solrDocuments) {
actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id")));
}
assertArrayEquals(expectedIds, actualIds);
}
use of org.apache.solr.common.SolrDocumentList in project lucene-solr by apache.
the class CloudMLTQParserTest method testLowMinWLValue.
@Test
public void testLowMinWLValue() throws Exception {
// Test out a low enough value of minwl and make sure we get the expected matches.
QueryResponse queryResponse = cluster.getSolrClient().query(COLLECTION, new SolrQuery("{!mlt qf=lowerfilt_u minwl=3 mintf=1}3"));
SolrDocumentList solrDocuments = queryResponse.getResults();
assertEquals("Expected to match 4 documents with a minwl of 3 but found more", 4, solrDocuments.size());
}
Aggregations