use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class RuntimeLibSearchComponent method prepare.
@Override
public void prepare(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
if (params.getBool(COMPONENT_NAME, true)) {
rb.rsp.add(COMPONENT_NAME, RuntimeLibSearchComponent.class.getName());
rb.rsp.add("loader", getClass().getClassLoader().getClass().getName());
rb.rsp.add("Version", "2");
}
super.process(rb);
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class TestExtendedDismaxParser method testAutoGeneratePhraseQueries.
public void testAutoGeneratePhraseQueries() throws Exception {
ModifiableSolrParams noSowParams = new ModifiableSolrParams();
noSowParams.add("df", "text");
ModifiableSolrParams sowFalseParams = new ModifiableSolrParams();
sowFalseParams.add("sow", "false");
sowFalseParams.add("df", "text");
ModifiableSolrParams sowTrueParams = new ModifiableSolrParams();
sowTrueParams.add("sow", "true");
sowTrueParams.add("df", "text");
for (SolrParams params : Arrays.asList(noSowParams, sowFalseParams)) {
try (SolrQueryRequest req = req(params)) {
// "text" has autoGeneratePhraseQueries="true"
QParser qParser = QParser.getParser("text:grackle", "edismax", req);
Query q = qParser.getQuery();
assertEquals("+(text:\"crow blackbird\" text:grackl)", q.toString());
}
}
try (SolrQueryRequest req = req(sowTrueParams)) {
QParser qParser = QParser.getParser("text:grackle", "edismax", req);
Query q = qParser.getQuery();
assertEquals("+spanOr([spanNear([text:crow, text:blackbird], 0, true), text:grackl])", q.toString());
}
for (SolrParams params : Arrays.asList(noSowParams, sowTrueParams, sowFalseParams)) {
try (SolrQueryRequest req = req(params)) {
// "text_sw" doesn't specify autoGeneratePhraseQueries => default false
QParser qParser = QParser.getParser("text_sw:grackle", "edismax", req);
Query q = qParser.getQuery();
assertEquals("+((+text_sw:crow +text_sw:blackbird) text_sw:grackl)", q.toString());
}
}
Stream.of(noSowParams, sowTrueParams, sowFalseParams).forEach(p -> p.add("qf", "text text_sw"));
for (SolrParams params : Arrays.asList(noSowParams, sowFalseParams)) {
try (SolrQueryRequest req = req(params)) {
QParser qParser = QParser.getParser("grackle", "edismax", req);
Query q = qParser.getQuery();
assertEquals("+((text:\"crow blackbird\" text:grackl)" + " | ((+text_sw:crow +text_sw:blackbird) text_sw:grackl))", q.toString());
qParser = QParser.getParser("grackle wi fi", "edismax", req);
q = qParser.getQuery();
assertEquals("+(((text:\"crow blackbird\" text:grackl) text:wifi)" + " | (((+text_sw:crow +text_sw:blackbird) text_sw:grackl) text_sw:wifi))", q.toString());
}
}
try (SolrQueryRequest req = req(sowTrueParams)) {
QParser qParser = QParser.getParser("grackle", "edismax", req);
Query q = qParser.getQuery();
assertEquals("+(spanOr([spanNear([text:crow, text:blackbird], 0, true), text:grackl])" + " | ((+text_sw:crow +text_sw:blackbird) text_sw:grackl))", q.toString());
qParser = QParser.getParser("grackle wi fi", "edismax", req);
q = qParser.getQuery();
assertEquals("+((spanOr([spanNear([text:crow, text:blackbird], 0, true), text:grackl])" + " | ((+text_sw:crow +text_sw:blackbird) text_sw:grackl)) (text:wi | text_sw:wi) (text:fi | text_sw:fi))", q.toString());
}
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class TestFiltering method testHossssSanity.
public void testHossssSanity() throws Exception {
clearIndex();
SolrParams match_0 = params("q", "{!frange v=val_i l=0 u=1}", "fq", "{!frange v=val_i l=1 u=1}", "fq", "{!frange v=val_i l=0 u=1}", "fq", "-_query_:\"{!frange v=val_i l=1 u=1}\"", "fq", "-_query_:\"{!frange v=val_i l=0 u=1}\"");
SolrParams match_1 = params("q", "{!frange v=val_i l=0 u=1}", "fq", "{!frange v=val_i l=0 u=1}", "fq", "{!frange v=val_i l=0 u=1}", "fq", "-_query_:\"{!frange v=val_i l=1 u=1}\"", "fq", "-_query_:\"{!frange v=val_i l=1 u=1}\"");
final int numDocs = 10;
for (int i = 0; i < numDocs; i++) {
String val = Integer.toString(i);
assertU(adoc("id", val, f, val));
}
assertU(commit());
// sanity check
assertJQ(req("q", "*:*"), "/response/numFound==" + numDocs);
// 1 then 0
assertJQ(req(match_1), "/response/numFound==1");
assertJQ(req(match_0), "/response/numFound==0");
// clear caches
assertU(commit());
// 0 then 1
assertJQ(req(match_0), "/response/numFound==0");
assertJQ(req(match_1), "/response/numFound==1");
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class TestPseudoReturnFields method testAugmentersGlobsExplicitAndScoreOhMy.
public void testAugmentersGlobsExplicitAndScoreOhMy() 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("q", "*:*", "rows", "1", "fl", StringUtils.join(fl.toArray(), ','));
final ModifiableSolrParams multiFl = params("q", "*:*", "rows", "1");
for (String item : fl) {
multiFl.add("fl", item);
}
for (SolrParams p : Arrays.asList(singleFl, multiFl)) {
assertQ(p.toString(), req(p), "//result[@numFound='5']", "//result/doc/str[@name='id']", "//result/doc/float[@name='score']", "//result/doc/str[@name='subject']", "//result/doc/int[@name='val_i']", "//result/doc/int[@name='[docid]']", "//result/doc/str[@name='[explain]']", "//result/doc[count(*)=6]");
}
}
}
use of org.apache.solr.common.params.SolrParams in project lucene-solr by apache.
the class TestPseudoReturnFields method testAugmentersGlobsExplicitAndScoreOhMyRTG.
public void testAugmentersGlobsExplicitAndScoreOhMyRTG() throws Exception {
Random random = random();
// NOTE: 'ssto' is the missing one
final List<String> fl = Arrays.asList("id", "[explain]", "score", "val_*", "subj*", "abs(val_i)", "[docid]");
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 p : Arrays.asList(singleFl, multiFl)) {
assertQ(id + ": " + p, req(p, "qt", "/get", "id", id, "wt", "xml"), "count(//doc)=1", "//doc/str[@name='id']", "//doc/int[@name='[docid]'][.>=-1]", "//doc/float[@name='abs(val_i)'][.='1.0']", // RTG: [explain] and score should be missing (ignored)
"//doc/int[@name='val_i'][.=1]", "//doc/str[@name='subject']", "//doc[count(*)=5]");
}
}
}
}
Aggregations