Package org.apache.solr.request

Examples of org.apache.solr.request.LocalSolrQueryRequest


      highligher = core.getHighlighter();
      Map args = new HashMap();
      snippetFieldAry = new String[]{snippetField};
      args.put(HighlightParams.FIELDS, snippetFieldAry);
      args.put(HighlightParams.HIGHLIGHT, "true");
      req = new LocalSolrQueryRequest(core, query.toString(), "", 0, 1, args) {
        @Override
        public SolrIndexSearcher getSearcher() {
          return sreq.getSearcher();
        }
      };
View Full Code Here


    public Map<String,String> args = new HashMap<String,String>();
    public LocalRequestFactory() {
    }
    public LocalSolrQueryRequest makeRequest(String ... q) {
      if (q.length==1) {
      return new LocalSolrQueryRequest(TestHarness.this.getCore(),
                                       q[0], qtype, start, limit, args);
      }

      return new LocalSolrQueryRequest(TestHarness.this.getCore(),new NamedList(Arrays.asList(q)));
    }
View Full Code Here

    params.put(MoreLikeThisParams.SIMILARITY_FIELDS, new String[]{"name,subword"});
    params.put(MoreLikeThisParams.INTERESTING_TERMS,new String[]{"details"});
    params.put(MoreLikeThisParams.MIN_TERM_FREQ,new String[]{"1"});
    params.put(MoreLikeThisParams.MIN_DOC_FREQ,new String[]{"1"});
   
    SolrQueryRequest mltreq = new LocalSolrQueryRequest( core, (SolrParams)mmparams);
    assertQ("morelikethis - tom cruise",mltreq
        ,"//result/doc[1]/int[@name='id'][.='46']"
        ,"//result/doc[2]/int[@name='id'][.='43']");
   
    params.put(CommonParams.Q, new String[]{"id:44"});
View Full Code Here

    args.put( CommonParams.Q, query );
    args.put( CommonParams.QT, "/elevate" );
    args.put( CommonParams.FL, "id,score" );
    args.put( "indent", "true" );
    //args.put( CommonParams.FL, "id,title,score" );
    SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
   
    assertQ("Make sure standard sort works as expected", req
            ,"//*[@numFound='3']"
            ,"//result/doc[1]/int[@name='id'][.='a']"
            ,"//result/doc[2]/int[@name='id'][.='b']"
View Full Code Here

    assertU(commit());
   
    Map<String,String> args = new HashMap<String, String>();
    args.put( CommonParams.Q, "title:test" );
    args.put( "indent", "true" );
    SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
   
   
    assertQ("Make sure they got in", req
            ,"//*[@numFound='3']"
            );
View Full Code Here

    assertU(delQ("id:[100 TO 110]"));
    assertU(commit());
  }

  void loadLocal(String... args) throws Exception {
    LocalSolrQueryRequest req =  (LocalSolrQueryRequest)req(args);

    // TODO: stop using locally defined streams once stream.file and
    // stream.body work everywhere
    List<ContentStream> cs = new ArrayList<ContentStream>();
    cs.add(new ContentStreamBase.FileStream(new File(filename)));
    req.setContentStreams(cs);
    h.query("/update/csv",req);
  }
View Full Code Here

    params.add(SpellCheckComponent.SPELLCHECK_COUNT, String.valueOf(5));
    params.add(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, String.valueOf(false));
    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
    SolrQueryResponse rsp;
    rsp = new SolrQueryResponse();
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    NamedList values = rsp.getValues();
    String cmdExec = (String) values.get("command");
    assertTrue("command is null and it shouldn't be", cmdExec != null);
    assertTrue(cmdExec + " is not equal to " + "build",
            cmdExec.equals("build") == true);
    NamedList spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    NamedList blue = (NamedList) suggestions.get("bluo");
    assertTrue(blue.get("numFound") + " is not equal to " + "5", blue
            .get("numFound").toString().equals("5") == true);
    Collection<String> theSuggestion = (Collection<String>) blue.get("suggestion");
    assertTrue("theSuggestion is null and it shouldn't be: " + blue,
            theSuggestion != null);
    assertTrue("theSuggestion Size: " + theSuggestion.size() + " is not: " + 5,
            theSuggestion.size() == 5);
    //we know there are at least 5, but now only get 3
    params.remove(SpellCheckComponent.SPELLCHECK_COUNT);
    params.remove(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS);
    params.remove(SpellCheckComponent.SPELLCHECK_BUILD);
    params.add(SpellCheckComponent.SPELLCHECK_COUNT, String.valueOf(3));
    params.add(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, String.valueOf(true));
    params.add(SpellCheckComponent.SPELLCHECK_BUILD, "false");
    rsp = new SolrQueryResponse();
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    values = rsp.getValues();

    spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    suggestions = (NamedList) spellCheck.get("suggestions");
View Full Code Here

    params.add(CommonParams.Q, "documemt");
    params.add(SpellCheckComponent.COMPONENT_NAME, "true");

    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
    SolrQueryResponse rsp = new SolrQueryResponse();
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    NamedList values = rsp.getValues();
    String cmdExec = (String) values.get("command");
    assertTrue("command is null and it shouldn't be", cmdExec != null);
    assertTrue(cmdExec + " is not equal to " + "build",
            cmdExec.equals("build") == true);
View Full Code Here

    params.add(SpellCheckComponent.SPELLCHECK_COLLATE, "true");

    SolrRequestHandler handler = core.getRequestHandler("spellCheckCompRH");
    SolrQueryResponse rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    NamedList values = rsp.getValues();
    NamedList spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    NamedList suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    String collation = (String) suggestions.get("collation");
    assertTrue("collation is null and it shouldn't be", collation != null);
    assertTrue(collation + " is not equal to " + "document", collation.equals("document") == true);
    params.remove(CommonParams.Q);
    params.add(CommonParams.Q, "documemt lowerfilt:broen^4");
    handler = core.getRequestHandler("spellCheckCompRH");
    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    values = rsp.getValues();
    spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
    collation = (String) suggestions.get("collation");
    assertTrue("collation is null and it shouldn't be", collation != null);
    assertTrue(collation + " is not equal to " + "document lowerfilt:brown^4", collation.equals("document lowerfilt:brown^4") == true);

    params.remove(CommonParams.Q);
    params.add(CommonParams.Q, "documemtsss broens");
    handler = core.getRequestHandler("spellCheckCompRH");
    rsp = new SolrQueryResponse();
    rsp.add("responseHeader", new SimpleOrderedMap());
    handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
    values = rsp.getValues();
    spellCheck = (NamedList) values.get("spellcheck");
    assertTrue("spellCheck is null and it shouldn't be", spellCheck != null);
    suggestions = (NamedList) spellCheck.get("suggestions");
    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
View Full Code Here

    args.put(CommonParams.Q, "lowerfilt:lazy lowerfilt:brown");
    args.put(CommonParams.QT, "spellCheckCompRH");
    args.put(SpellCheckComponent.SPELLCHECK_BUILD, "true");
    args.put(SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
    args.put(SpellCheckComponent.COMPONENT_NAME, "true");
    SolrQueryRequest req = new LocalSolrQueryRequest(core, new MapSolrParams(
            args));

    assertQ("Make sure correct spellings are signalled in the response", req,
            "//*[@numFound='1']", "//result/doc[1]/int[@name='id'][.='1']",
            "//*/lst[@name='suggestions']");
 
View Full Code Here

TOP

Related Classes of org.apache.solr.request.LocalSolrQueryRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.