Examples of QueryResponse


Examples of org.apache.solr.client.solrj.response.QueryResponse

    solrServer.commit(false, true, true);
  }
 
  private int queryResultSetSize(String query) throws SolrServerException, IOException {
    commit();
    QueryResponse rsp = query(query);
    LOGGER.debug("rsp: {}", rsp);
    int size = rsp.getResults().size();
    return size;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

    return size;
  }
 
  private QueryResponse query(String query) throws SolrServerException, IOException {
    commit();
    QueryResponse rsp = solrServer.query(new SolrQuery(query).setRows(Integer.MAX_VALUE));
    LOGGER.debug("rsp: {}", rsp);
    return rsp;
  }
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

      SolrQuery query = new SolrQuery();
      query.setQuery("units_i:2");
      query.addSortField("value_i", SolrQuery.ORDER.asc);
      query.setRows(Integer.MAX_VALUE);

      QueryResponse response = client.query(query);
      SolrDocumentList results = response.getResults();
      Assert.assertEquals(results.getNumFound(), docCount / 10);
      for (int i = 0; i < results.size(); i++) {
        SolrDocument doc = results.get(i);

        int docId = (i * 10) + 2;
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

      SolrQuery query = new SolrQuery();
      query.setQuery("value_i:[* TO 9]");
      query.addSortField("value_i", SolrQuery.ORDER.asc);
      query.setRows(Integer.MAX_VALUE);

      QueryResponse response = client.query(query);
      SolrDocumentList results = response.getResults();
      Assert.assertEquals(results.getNumFound(), 10);
      for (int i = 0; i < results.size(); i++) {
        SolrDocument doc = results.get(i);

        int docId = i;
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

    //<start id="solrj-search-1"/>
    SolrQuery queryParams = new SolrQuery();//<co id="solrj-search.co.query"/>
    queryParams.setFields("description", "title");//<co id="solrj-search.co.fields"/>
    queryParams.setQuery("description:win OR description:all");//<co id="solrj-search.co.terms"/>
    queryParams.setRows(10);
    QueryResponse response = solr.query(queryParams);//<co id="solrj-search.co.process"/>
    assertTrue("response is null and it shouldn't be", response != null);
    SolrDocumentList documentList = response.getResults();
    System.out.println("Docs: " + documentList);
    assertTrue("response.getResults() Size: " + documentList.size() +
            " is not: " + 3, documentList.size() == 3);
    /*
<calloutlist>
    <callout arearefs="solrj-search.co.query"><para>A <classname>SolrQuery</classname> is a easy-to-use container for creating the most common types of queries.</para></callout>
    <callout arearefs="solrj-search.co.fields"><para>Set the names of the Fields to be returned in the documents.</para></callout>
    <callout arearefs="solrj-search.co.terms"><para>Set the terms to search.  The "OR" is a boolean operator which allows one or the other or both to be present in the query.</para></callout>
    <callout arearefs="solrj-search.co.process"><para>Submit the query to Solr and get back a <classname>QueryResponse</classname> which contains the results of the search.</para></callout>

</calloutlist>
*/
    //<end id="solrj-search-1"/>

    //<start id="solrj-search-dismax"/>
    queryParams.setQuery("lazy");
    queryParams.setParam("defType", "dismax");//<co id="solrj-search.co.dismax"/>
    queryParams.set("qf", "title^3 description^10");//<co id="sorlj-search.co.qf"/>
    System.out.println("Query: " + queryParams);
    response = solr.query(queryParams);
    assertTrue("response is null and it shouldn't be", response != null);
    documentList = response.getResults();
    assertTrue("documentList Size: " + documentList.size() +
            " is not: " + 2, documentList.size() == 2);
/*
<calloutlist>
    <callout arearefs="solrj-search.co.dismax"><para>Tell Solr to use the <classname>DisMax</classname> Query Parser (named dismax in solrconfig.xml). </para></callout>
    <callout arearefs="sorlj-search.co.qf"><para>The DisMax parser will search across the fields given by the "qf" parameter and boosts the terms accordingly.</para></callout>

</calloutlist>
*/
    //<end id="solrj-search-dismax"/>

    //<start id="solrj-search-facets"/>
    queryParams = new SolrQuery();
    queryParams.setQuery("description:number");
    queryParams.setRows(10);
    queryParams.setFacet(true);//<co id="solrj-search-facets-facetOn"/>
    queryParams.set("facet.field", "date");//<co id="solrj-search-facets-date"/>
    response = solr.query(queryParams);
    assertTrue("response is null and it shouldn't be", response != null);
    System.out.println("Query: " + queryParams);
    documentList = response.getResults();
    assertTrue("documentList Size: " + documentList.size() +
            " is not: " + 10, documentList.size() == 10);
    System.out.println("Facet Response: " + response.getResponse());//<co id="solrj-search-facets-print"/>
    /*
<calloutlist>
  <callout arearefs="solrj-search-facets-facetOn"><para>Turn on faceting for this query</para></callout>
  <callout arearefs="solrj-search-facets-date"><para>Specify the Field to facet on</para></callout>
  <callout arearefs="solrj-search-facets-print"><para>Print out the facet information</para></callout>

</calloutlist>
*/
    //<end id="solrj-search-facets"/>
    //<start id="solrj-search-more-like-this"/>
    queryParams = new SolrQuery();
    queryParams.setQueryType("/mlt");//<co id="solrj-search.co.mlt"/>
    queryParams.setQuery("description:number");
    queryParams.set("mlt.match.offset", "0");//<co id="solrj-search.co.mlt.off"/>
    queryParams.setRows(1);
    queryParams.set("mlt.fl", "description, title");//<co id="solrj-search.co.mlt.fl"/>
    response = solr.query(queryParams);
    assertTrue("response is null and it shouldn't be", response != null);
    SolrDocumentList results = (SolrDocumentList) response.getResponse().get("match");
    assertTrue("results Size: " + results.size() + " is not: " + 1,
            results.size() == 1);
    /*
<calloutlist>
    <callout arearefs="solrj-search.co.mlt"><para>Create a "MoreLikeThis" search to find similar documents to the specified document.</para></callout>
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

  @Override
  public QueryResponse process( SolrServer server ) throws SolrServerException
  {
    try {
      long startTime = System.currentTimeMillis();
      QueryResponse res = new QueryResponse( server.request( this ), server );
      res.setElapsedTime( System.currentTimeMillis()-startTime );
      return res;
    } catch (SolrServerException e){
      throw e;
    } catch (Exception e) {
      throw new SolrServerException("Error executing query", e);
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

        query.setParam(CommonParams.HIGOHB,true);
        query.setParam("mlogtime", fmt.format(new Date()));

        query.setParam("rows", "0");
        query.setQuery("*:*");
        QueryResponse qr3 = server.query(query);
        SolrDocumentList result3 = qr3.getResults();
        if(result3!=null)
        {
          return result3.getNumFound();
        }else{
          SolrCore.log.info("checkSolrRecord result is null "+
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

  private void checkAZombieServer(ServerWrapper zombieServer) {
    long currTime = System.currentTimeMillis();
    checkLock.lock();
    try {
      zombieServer.lastChecked = currTime;
      QueryResponse resp = zombieServer.solrServer.query(solrQuery);
      if (resp.getStatus() == 0) {
        //server has come back up
        zombieServer.lastUsed = currTime;
        zombieServers.remove(zombieServer);
        aliveServers.add(zombieServer);
        zombieServer.failedPings = 0;
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

  public static QueryResponse fetchGroupCrcQr(SolrQuery query,CommonsHttpSolrServer server,JSONObject jsonObj,String key) throws SolrServerException, JSONException
  {
    String crcid=java.util.UUID.randomUUID().toString();

    query.set("mdrill.crc.key.set", crcid);
    QueryResponse qr = server.query(query, SolrRequest.METHOD.POST);
    jsonObj.put(key+"_qr", qr.getTimetaken(8).toString());

    query.remove("mdrill.crc.key.set");
    query.set("mdrill.crc.key.get", crcid);
    query.set("mdrill.crc.key.get.crclist", WebServiceParams.getGroupByCrc(qr));
    QueryResponse qrCrc = server.query(query, SolrRequest.METHOD.POST);
    jsonObj.put(key+"_qrCrc", qrCrc.getTimetaken(4).toString());

    query.remove("mdrill.crc.key.set");
    query.remove("mdrill.crc.key.get");
    query.remove("mdrill.crc.key.get.crclist");
    setGroupByCrc(qr, qrCrc);
View Full Code Here

Examples of org.apache.solr.client.solrj.response.QueryResponse

  public static QueryResponse fetchDetailCrcQr(SolrQuery query,CommonsHttpSolrServer server,JSONObject jsonObj,String key) throws SolrServerException, JSONException
  {
    String crcid=java.util.UUID.randomUUID().toString();

    query.set("mdrill.crc.key.set", crcid);
    QueryResponse qr = server.query(query, SolrRequest.METHOD.POST);
    jsonObj.put(key+"_qr", qr.getTimetaken(8).toString());
    query.remove("mdrill.crc.key.set");
    query.set("mdrill.crc.key.get", crcid);
    query.set("mdrill.crc.key.get.crclist", WebServiceParams.getDetailCrc(qr));
    QueryResponse qrCrc = server.query(query, SolrRequest.METHOD.POST);
    jsonObj.put(key+"_qrCrc", qrCrc.getTimetaken(4).toString());

    query.remove("mdrill.crc.key.set");
    query.remove("mdrill.crc.key.get");
    query.remove("mdrill.crc.key.get.crclist");
    setDetailCrc(qr, qrCrc);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.