use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class TestNestedDocsSort method testCachehits.
public void testCachehits() {
final SolrQueryRequest req = req();
try {
final SolrCache cache = req.getSearcher().getCache("perSegFilter");
assertNotNull(cache);
final Map<String, Object> state = cache.getMetricsSnapshot();
String lookupsKey = null;
for (String key : state.keySet()) {
if (key.endsWith(".lookups")) {
lookupsKey = key;
break;
}
}
Number before = (Number) state.get(lookupsKey);
parse("childfield(name_s1,$q) asc");
Number after = (Number) cache.getMetricsSnapshot().get(lookupsKey);
assertEquals("parsing bjq lookups parent filter," + "parsing sort spec lookups parent and child filters, " + "hopefully for the purpose", 3, after.intValue() - before.intValue());
} finally {
req.close();
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class TestNestedDocsSort method parse.
private SortField parse(String a) {
final SolrQueryRequest req = req("q", "{!parent which=type_s1:parent}whatever_s1:foo", "q2", "{!parent which=type_s1:parent}nomater_s1:what", "notbjq", "foo_s1:bar");
try {
final SortSpec spec = SortSpecParsing.parseSortSpec(a, req);
assertNull(spec.getSchemaFields().get(0));
final Sort sort = spec.getSort();
final SortField field = sort.getSort()[0];
assertNotNull(field);
return field;
} finally {
req.close();
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class TestScoreJoinQPNoScore method testNotEquals.
public void testNotEquals() throws SyntaxError, IOException {
try (SolrQueryRequest req = req("*:*")) {
Query x = QParser.getParser("{!join from=dept_id_s to=dept_ss score=none}text_t:develop", req).getQuery();
Query y = QParser.getParser("{!join from=dept_ss to=dept_ss score=none}text_t:develop", req).getQuery();
assertFalse("diff from fields produce equal queries", x.equals(y));
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class TestScoreJoinQPNoScore method testJoinQueryType.
public void testJoinQueryType() throws SyntaxError, IOException {
SolrQueryRequest req = null;
try {
final String score = whateverScore();
req = req("{!join from=dept_id_s to=dept_ss" + score + "}text_t:develop");
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
{
final Query query = QParser.getParser(req.getParams().get("q"), req).getQuery();
final Query rewrittenQuery = query.rewrite(req.getSearcher().getIndexReader());
assertEquals(rewrittenQuery + " is expected to be from Solr", ScoreJoinQParserPlugin.class.getPackage().getName(), rewrittenQuery.getClass().getPackage().getName());
}
{
final Query query = QParser.getParser("{!join from=dept_id_s to=dept_ss}text_t:develop", req).getQuery();
final Query rewrittenQuery = query.rewrite(req.getSearcher().getIndexReader());
assertEquals(rewrittenQuery + " is expected to be from Solr", JoinQParserPlugin.class.getPackage().getName(), rewrittenQuery.getClass().getPackage().getName());
}
} finally {
if (req != null) {
req.close();
}
SolrRequestInfo.clearRequestInfo();
}
}
use of org.apache.solr.request.SolrQueryRequest in project lucene-solr by apache.
the class TestHdfsUpdateLog method testFSThreadSafety.
@Test
public void testFSThreadSafety() throws Exception {
final SolrQueryRequest req = req();
final UpdateHandler uhandler = req.getCore().getUpdateHandler();
((DirectUpdateHandler2) uhandler).getCommitTracker().setTimeUpperBound(100);
((DirectUpdateHandler2) uhandler).getCommitTracker().setOpenSearcher(false);
final UpdateLog ulog = uhandler.getUpdateLog();
clearIndex();
assertU(commit());
// we hammer on init in a background thread to make
// sure we don't run into any filesystem already closed
// problems (SOLR-7113)
Thread thread = new Thread() {
public void run() {
int cnt = 0;
while (true) {
ulog.init(uhandler, req.getCore());
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
if (cnt++ > 50) {
break;
}
}
}
};
Thread thread2 = new Thread() {
public void run() {
int cnt = 0;
while (true) {
assertU(adoc("id", Integer.toString(cnt)));
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
if (cnt++ > 500) {
break;
}
}
}
};
thread.start();
thread2.start();
thread.join();
thread2.join();
}
Aggregations