org.apache.solr.request.SolrQueryRequest Java Examples

The following examples show how to use org.apache.solr.request.SolrQueryRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryEqualityTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void testFuncSingleValueMathFuncs() throws Exception {
  SolrQueryRequest req = req("myVal","45", "myField","foo_i");
  for (final String func : new String[] {"abs","rad","deg","sqrt","cbrt",
                                         "log","ln","exp","sin","cos","tan",
                                         "asin","acos","atan",
                                         "sinh","cosh","tanh",
                                         "ceil","floor","rint"}) {
    try {
      assertFuncEquals(req,
                       func + "(field(foo_i))", func + "(foo_i)",
                       func + "($myField)");
      assertFuncEquals(req, func + "(45)", func+ "($myVal)");
    } finally {
      req.close();
    }
  }
}
 
Example #2
Source File: TestOverriddenPrefixQueryForCustomFieldType.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.lucene.search.QueryUtils#check
 * @see org.apache.lucene.search.QueryUtils#checkEqual
 */
protected void assertQueryEquals(final SolrQueryRequest req,
                                 final String... inputs) throws Exception {

  final Query[] queries = new Query[inputs.length];

  try {
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
    for (int i = 0; i < inputs.length; i++) {
      queries[i] = (QParser.getParser(inputs[i], req).getQuery());
    }
  } finally {
    SolrRequestInfo.clearRequestInfo();
  }

  for (int i = 0; i < queries.length; i++) {
    org.apache.lucene.search.QueryUtils.check(queries[i]);
    for (int j = i; j < queries.length; j++) {
      org.apache.lucene.search.QueryUtils.checkEqual(queries[i], queries[j]);
    }
  }
}
 
Example #3
Source File: ExtractingDocumentLoader.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public ExtractingDocumentLoader(SolrQueryRequest req, UpdateRequestProcessor processor,
                         TikaConfig config, ParseContextConfig parseContextConfig,
                                SolrContentHandlerFactory factory) {
  this.params = req.getParams();
  this.core = req.getCore();
  this.config = config;
  this.parseContextConfig = parseContextConfig;
  this.processor = processor;

  templateAdd = new AddUpdateCommand(req);
  templateAdd.overwrite = params.getBool(UpdateParams.OVERWRITE, true);
  templateAdd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1);

  //this is lightweight
  autoDetectParser = new AutoDetectParser(config);
  this.factory = factory;
  
  ignoreTikaException = params.getBool(ExtractingParams.IGNORE_TIKA_EXCEPTION, false);
}
 
Example #4
Source File: TestXJoinValueSourceParser.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void initialise() throws Exception {
  SolrCore core = h.getCore();

  XJoinSearchComponent xjsc = (XJoinSearchComponent)core.getSearchComponent(componentName);
  DummyXJoinResultsFactory xjrf = (DummyXJoinResultsFactory)xjsc.getResultsFactory();
  XJoinResults<?> results = xjrf.getResults(null);
  
  // mock SolrQueryRequest with join results in the context
  sqr = mock(SolrQueryRequest.class);
  Map<Object, Object> context = new HashMap<>();
  context.put(xjsc.getResultsTag(), results);
  when(sqr.getContext()).thenReturn(context);
  when(sqr.getCore()).thenReturn(core);
  
  searcher = core.getRegisteredSearcher().get();
  
  missingDoc = new Integer(xjrf.getMissingId());
}
 
Example #5
Source File: QuerqyDismaxQParserWithSolrSynonymsTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatPF23FWorksWithSynonymRewriting() {

   SolrQueryRequest req = req("q", "a b c d",
         DisMaxParams.QF, "f1 f2^0.9",
         DisMaxParams.PF2, "f1~2^2.1",
         DisMaxParams.PF3, "f2~3^3.9",
         "defType", "querqy",
         "debugQuery", "true");

   assertQ("ps2/3 with synonyms not working",
         req,
         "//str[@name='parsedquery'][contains(.,'(f1:\"a b\"~2 f1:\"b c\"~2 f1:\"c d\"~2)^2.1')]",
         "//str[@name='parsedquery'][contains(.,'f2:\"a b c\"~3 f2:\"b c d\"~3)^3.9')]");

   req.close();

}
 
Example #6
Source File: DefaultQuerqyDismaxQParserWithCommonRulesTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatNegativeRawQueryFilterIsApplied() {
    String q = "qnegraw2";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2 f3",
            "defType", "querqy",
            "echoParams", "all",
            "debugQuery", "on"
    );

    assertQ("Purely negative filter fails for raw query",
            req,
            "//result[@name='response' and @numFound='1']/doc[1]/str[@name='id'][text()='11']"
    );



    req.close();
}
 
Example #7
Source File: SuggestionRequestHandlerTest.java    From vind with Apache License 2.0 6 votes vote down vote up
@Test
public void sortingTest2() {
    ModifiableSolrParams params = new ModifiableSolrParams();

    params.add(SuggestionRequestParams.SUGGESTION,"true");
    params.add(CommonParams.QT,"/suggester");
    params.add(CommonParams.Q,"ku");
    params.add(SuggestionRequestParams.SUGGESTION_FIELD,"dynamic_multi_stored_suggest_analyzed_place");

    SolrQueryRequest req = new LocalSolrQueryRequest( core, params );

    assertQ("suggester - test single sorting for 'ku' with 2 facets", req,
            "//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_analyzed_place']/int[@name='kuala Lumpur'][.='2']",
            "//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_analyzed_place']/int[1][.='2']",
            "//response/lst[@name='suggestions']/lst[@name='suggestion_facets']/lst[@name='dynamic_multi_stored_suggest_analyzed_place']/int[@name='Havanna kuba'][.='1']");
}
 
Example #8
Source File: JoinQParserPlugin.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
  final JoinQParserPlugin plugin = this;

  return new QParser(qstr, localParams, params, req) {

    @Override
    public Query parse() throws SyntaxError {
      if (localParams != null && localParams.get(METHOD) != null) {
        // TODO Make sure 'method' is valid value here and give users a nice error
        final Method explicitMethod = Method.valueOf(localParams.get(METHOD));
        return explicitMethod.makeFilter(this, plugin);
      }

      // Legacy join behavior before introduction of SOLR-13892
      if(localParams!=null && localParams.get(ScoreJoinQParserPlugin.SCORE)!=null) {
        return new ScoreJoinQParserPlugin().createParser(qstr, localParams, params, req).parse();
      } else {
        return Method.index.makeFilter(this, plugin);
      }
    }
  };
}
 
Example #9
Source File: LTRScoringQuery.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void createWeightsParallel(IndexSearcher searcher, boolean needsScores,
    List<Feature.FeatureWeight > featureWeights, Collection<Feature> features) throws RuntimeException {

  final SolrQueryRequest req = getRequest();
  List<Future<Feature.FeatureWeight> > futures = new ArrayList<>(features.size());
  try{
    for (final Feature f : features) {
      CreateWeightCallable callable = new CreateWeightCallable(f, searcher, needsScores, req);
      RunnableFuture<Feature.FeatureWeight> runnableFuture = new FutureTask<>(callable);
      querySemaphore.acquire(); // always acquire before the ltrSemaphore is acquired, to guarantee a that the current query is within the limit for max. threads
      ltrThreadMgr.acquireLTRSemaphore();//may block and/or interrupt
      ltrThreadMgr.execute(runnableFuture);//releases semaphore when done
      futures.add(runnableFuture);
    }
    //Loop over futures to get the feature weight objects
    for (final Future<Feature.FeatureWeight> future : futures) {
      featureWeights.add(future.get()); // future.get() will block if the job is still running
    }
  } catch (Exception e) { // To catch InterruptedException and ExecutionException
    log.info("Error while creating weights in LTR: InterruptedException", e);
    throw new RuntimeException("Error while creating weights in LTR: " + e.getMessage(), e);
  }
}
 
Example #10
Source File: InfoLoggingTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
public void testThatLogOutputIsTurnedOffByDefault() {

        String q = "k";

        SolrQueryRequest req = req("q", q,
                DisMaxParams.QF, "f1 f2 f3",
                "defType", "querqy"
        );

        assertQ("Logging multiple logs for same input false",
                req,
                "count(//lst[@name='querqy.infoLog']/arr) = 0"
        );

        req.close();
    }
 
Example #11
Source File: DefaultQuerqyDismaxQParserWithCommonRulesGZIPTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testSolrFilterQuery() {

    String q = "a k";

    SolrQueryRequest req = req("q", q,
          DisMaxParams.QF, "f1 f2 f3",
          DisMaxParams.MM, "1",
          QueryParsing.OP, "OR",
          "defType", "querqy"
          );

    assertQ("Solr filter query fails",
          req,
          "//result[@name='response' and @numFound='1']"

    );

    req.close();
}
 
Example #12
Source File: BasicFunctionalityTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotLazyField() throws IOException {

  assertU(adoc("id", "7777",
               "title", "keyword",
               "test_hlt", mkstr(20000)));

  assertU(commit());
  SolrCore core = h.getCore();
 
  SolrQueryRequest req = req("q", "id:7777", "fl", "id,title,test_hlt");
  SolrQueryResponse rsp = new SolrQueryResponse();
  core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);

  DocList dl = ((ResultContext) rsp.getResponse()).getDocList();
  Document d = req.getSearcher().doc(dl.iterator().nextDoc());
  // ensure field in fl is not lazy
  assertFalse( ((Field) d.getField("test_hlt")).getClass().getSimpleName().equals("LazyField"));
  assertFalse( ((Field) d.getField("title")).getClass().getSimpleName().equals("LazyField"));
  req.close();
}
 
Example #13
Source File: CommonRulesDeleteLastTermTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatMatchAllQueryIsAppliedIfQueryContainsBoostUpQueryAndHasNoTerm() {
    String q = "d";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            "debugQuery", "on",
            "defType", "querqy");

    assertQ("",
            req,
            "//result[@name='response' and @numFound='4']"
    );
    req.close();

}
 
Example #14
Source File: NeedsScoresTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testBoostIsAddedForNeedsScoresTrue() {
    String q = "qup";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2",
            QueryParsing.OP, "OR",
            NEEDS_SCORES, "true",
            "defType", "querqy",
            "debugQuery", "true"
    );

    assertQ("Boost not added",
            req,
            "//result[@name='response'][@numFound='2']",
            // the parsed query must contain the boost terms:
            "//str[@name='parsedquery'][contains(.,'f1:u100')]",
            "//str[@name='parsedquery'][contains(.,'f2:u100')]",
            "//str[@name='parsedquery'][not(contains(.,'ConstantScore'))]");
    req.close();
}
 
Example #15
Source File: SolrInformationServer.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public AclChangeSet getMaxAclChangeSetIdAndCommitTimeInIndex()
{
    try (SolrQueryRequest request = newSolrQueryRequest())
    {
        SolrDocument aclState = getState(core, request, "TRACKER!STATE!ACLTX");
        if (aclState != null)
        {
            long id = this.getFieldValueLong(aclState, FIELD_S_ACLTXID);
            long commitTime = this.getFieldValueLong(aclState, FIELD_S_ACLTXCOMMITTIME);
            int aclCount = -1; // Irrelevant for this method
            return new AclChangeSet(id, commitTime, aclCount);
        }
        return new AclChangeSet(0, 0, -1);
    }
}
 
Example #16
Source File: RangeFacet.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void createFacetValueExecuters(final Filter filter, SolrQueryRequest queryRequest, Consumer<FacetValueQueryExecuter> consumer) {
  // Computes the end points of the ranges in the rangeFacet
  final FacetRangeGenerator<? extends Comparable<?>> rec = FacetRangeGenerator.create(this);
  final SchemaField sf = field;

  // Create a rangeFacetAccumulator for each range and
  // collect the documents for that range.
  for (FacetRange range : rec.getRanges()) {
    Query q = sf.getType().getRangeQuery(null, sf, range.lower, range.upper, range.includeLower,range.includeUpper);
    // The searcher sends docIds to the RangeFacetAccumulator which forwards
    // them to <code>collectRange()</code> in this class for collection.
    Query rangeQuery = QueryUtils.combineQueryAndFilter(q, filter);

    ReductionDataCollection dataCol = collectionManager.newDataCollection();
    reductionData.put(range.toString(), dataCol);
    consumer.accept(new FacetValueQueryExecuter(dataCol, rangeQuery));
  }
}
 
Example #17
Source File: CommonRulesDeleteLastTermTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoMatchAfterDeletingLastTerm() {
    String q = "b";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1",
            "debugQuery", "on",
            "defType", "querqy");

    assertQ("",
            req,
            "//result[@name='response' and @numFound='0']"
    );
    req.close();

}
 
Example #18
Source File: CriteriaSelectionTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatDefaultStrategyIsAppliedIfNoCriteriaParamIsSet() {
    SolrQueryRequest req = req("q", "input1 input2",
            DisMaxParams.QF, "f1",
            DisMaxParams.MM, "1",
            getStrategyParamName(REWRITER_ID_1), "criteria",
            "defType", "querqy",
            "debugQuery", "true"
    );

    assertQ("default SelectionStrategy doesn't work",
            req,
            "//result[@name='response' and @numFound='3']"
    );

    req.close();
}
 
Example #19
Source File: QuerqyDismaxQParserWithSolrSynonymsTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatPFWorksWithSynonymRewriting() {

   SolrQueryRequest req = req("q", "a b",
         DisMaxParams.QF, "f1 f2^0.9",
         DisMaxParams.PF, "f1^0.5",
         "defType", "querqy",
         "debugQuery", "true");

   assertQ("ps with synonyms not working",
         req,
         "//str[@name='parsedquery'][contains(.,'PhraseQuery(f1:\"a b\")^0.5')]");

   req.close();

}
 
Example #20
Source File: TestCollectionAPIs.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
void invokeAction(SolrQueryRequest req, SolrQueryResponse rsp,
                  CoreContainer cores,
                  CollectionParams.CollectionAction action,
                  CollectionOperation operation) throws Exception {
  Map<String, Object> result = null;
  if (action == CollectionParams.CollectionAction.COLLECTIONPROP) {
    //Fake this action, since we don't want to write to ZooKeeper in this test
    result = new HashMap<>();
    result.put(NAME, req.getParams().required().get(NAME));
    result.put(PROPERTY_NAME, req.getParams().required().get(PROPERTY_NAME));
    result.put(PROPERTY_VALUE, req.getParams().required().get(PROPERTY_VALUE));
  } else {
    result = operation.execute(req, rsp, this);
  }
  if (result != null) {
    result.put(QUEUE_OPERATION, operation.action.toLower());
    rsp.add(ZkNodeProps.class.getName(), new ZkNodeProps(result));
  }
}
 
Example #21
Source File: InfoLoggingTest.java    From querqy with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatLogPropertyIsReturnedEvenIfIdIsConfigured() {

    String q = "k";

    SolrQueryRequest req = req("q", q,
            DisMaxParams.QF, "f1 f2 f3",
            QuerqyDismaxParams.INFO_LOGGING, "on",
            "defType", "querqy"
    );

    assertQ("Log not returned if ID is configured",
            req,
            "//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" +
                    "str[text() = 'LOG for k']",
            "count(//lst[@name='querqy.infoLog']/arr[@name='common1']/lst/arr[@name='APPLIED_RULES']/" +
                    "str) = 1"
    );

    req.close();
}
 
Example #22
Source File: EdismaxQueryConverter.java    From solr-researcher with Apache License 2.0 5 votes vote down vote up
@Override
public List<Clause> convert(String query, SolrQueryRequest req) {
  try {
    Map<String, Float> queryFields = DisMaxQParser.parseQueryFields(req.getSchema(), req.getParams());
    return splitIntoClauses(query, queryFields.keySet(), false);
  } catch (SyntaxError e) {
    throw new RuntimeException();
  }
}
 
Example #23
Source File: InfoHandler.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
  // Make sure the cores is enabled
  CoreContainer cores = getCoreContainer();
  if (cores == null) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
            "Core container instance missing");
  }

  String path = (String) req.getContext().get(PATH);
  handle(req, rsp, path);
}
 
Example #24
Source File: SolrTestCaseJ4.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/** Validates a query matches some XPath test expressions and closes the query */
public static void assertQ(String message, SolrQueryRequest req, String... tests) {
  try {
    String m = (null == message) ? "" : message + " "; // TODO log 'm' !!!
    //since the default (standard) response format is now JSON
    //need to explicitly request XML since this class uses XPath
    ModifiableSolrParams xmlWriterTypeParams = new ModifiableSolrParams(req.getParams());
    xmlWriterTypeParams.set(CommonParams.WT,"xml");
    //for tests, let's turn indention off so we don't have to handle extraneous spaces
    xmlWriterTypeParams.set("indent", xmlWriterTypeParams.get("indent", "off"));
    req.setParams(xmlWriterTypeParams);
    String response = h.query(req);

    if (req.getParams().getBool("facet", false)) {
      // add a test to ensure that faceting did not throw an exception
      // internally, where it would be added to facet_counts/exception
      String[] allTests = new String[tests.length+1];
      System.arraycopy(tests,0,allTests,1,tests.length);
      allTests[0] = "*[count(//lst[@name='facet_counts']/*[@name='exception'])=0]";
      tests = allTests;
    }

    String results = BaseTestHarness.validateXPath(response, tests);

    if (null != results) {
      String msg = "REQUEST FAILED: xpath=" + results
          + "\n\txml response was: " + response
          + "\n\trequest was:" + req.getParamString();

      log.error(msg);
      throw new RuntimeException(msg);
    }

  } catch (XPathExpressionException e1) {
    throw new RuntimeException("XPath is invalid", e1);
  } catch (Exception e2) {
    SolrException.log(log,"REQUEST FAILED: " + req.getParamString(), e2);
    throw new RuntimeException("Exception during query", e2);
  }
}
 
Example #25
Source File: QueryEqualityTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void testFuncConcat() throws Exception {
  SolrQueryRequest req = req("myField","bar_f","myOtherField","bar_t");

  try {
    assertFuncEquals(req,
        "concat(bar_f,bar_t)",
        "concat($myField,bar_t)",
        "concat(bar_f,$myOtherField)",
        "concat($myField,$myOtherField)");

  } finally {
    req.close();
  }
}
 
Example #26
Source File: ReSearcherHandler.java    From solr-researcher with Apache License 2.0 5 votes vote down vote up
public SolrQueryResponse handleSuggestionResponseRequest(ReSearcherRequestContext ctx, ModifiableSolrParams params, String componentName, List<SearchComponent> components) throws Exception {
  params.set(componentName, "false");

  SolrQueryRequest req = new SolrQueryRequestBase(ctx.getCore(), params) {};
  SolrQueryResponse rsp = new SolrQueryResponse();
  ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
  
  try {
    handleSuggestionRequest(ctx, rb, components, false);
  } finally {
    req.close();
  }
  
  return rsp;
}
 
Example #27
Source File: DocumentAnalysisRequestHandlerTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testCharsetOutsideDocument() throws Exception {
  final byte[] xmlBytes = (
    "<docs>\r\n" +
    " <doc>\r\n" +
    "  <field name=\"id\">Müller</field>\r\n" +
    " </doc>" +
    "</docs>"
  ).getBytes(StandardCharsets.ISO_8859_1);
  
  // we declare a content stream with charset:
  final ContentStream cs = new ByteStream(xmlBytes, "application/xml; charset=ISO-8859-1");
  
  ModifiableSolrParams params = new ModifiableSolrParams();
  SolrQueryRequest req = new SolrQueryRequestBase(h.getCore(), params) {
    @Override
    public Iterable<ContentStream> getContentStreams() {
      return Collections.singleton(cs);
    }
  };

  DocumentAnalysisRequest request = handler.resolveAnalysisRequest(req);
  assertNotNull(request);
  final List<SolrInputDocument> documents = request.getDocuments();
  assertNotNull(documents);
  assertEquals(1, documents.size());
  SolrInputDocument doc = documents.get(0);
  assertEquals("Müller", doc.getField("id").getValue());
}
 
Example #28
Source File: SpellCheckCollatorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testZeroTries() throws Exception
{
  SolrCore core = h.getCore();
  SearchComponent speller = core.getSearchComponent("spellcheck");
  assertTrue("speller is null and it shouldn't be", speller != null);
  
  ModifiableSolrParams params = new ModifiableSolrParams();   
  params.add(SpellCheckComponent.COMPONENT_NAME, "true");
  params.add(SpellCheckComponent.SPELLCHECK_BUILD, "true");
  params.add(SpellCheckComponent.SPELLCHECK_COUNT, "10");   
  params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0");
  params.add(SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "2");
  params.add(CommonParams.Q, "lowerfilt:(+fauth)");
  SolrRequestHandler handler = core.getRequestHandler("/spellCheckCompRH");
  SolrQueryResponse rsp = new SolrQueryResponse();
  rsp.addResponseHeader(new SimpleOrderedMap());
  SolrQueryRequest req = new LocalSolrQueryRequest(core, params);
  handler.handleRequest(req, rsp);
  req.close();
  NamedList values = rsp.getValues();
  NamedList spellCheck = (NamedList) values.get("spellcheck");
  NamedList collationList = (NamedList) spellCheck.get("collations");
  List<?> collations = (List<?>) collationList.getAll("collation");
  assertTrue(collations.size() == 2);
}
 
Example #29
Source File: RecordingUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("resource")
public synchronized UpdateRequestProcessor getInstance(SolrQueryRequest req, 
                                                       SolrQueryResponse rsp, 
                                                       UpdateRequestProcessor next ) {
  return recording ? new RecordingUpdateRequestProcessor(commandQueue, next) : next;
}
 
Example #30
Source File: QuerySegmenterQParserTest.java    From query-segmenter with Apache License 2.0 5 votes vote down vote up
/**
 * The query "solr" should be rewritten to "project:Solr" thus limiting the results to only document 1.
 */
@Test
public void test_only_solr_project_with_request_handler() {

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add(CommonParams.QT, DISMAX_QPARSER);
  params.add("qq", "solr");

  SolrQueryRequest req = request(params);

  assertQ(req, "//result[@name='response'][@numFound='1']",
      "//result[@name='response']/doc[1]/str[@name='id'][.='1']");
}