Package org.apache.solr.client.solrj.response

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


  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

  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

      .set("fl", "*,score")
      .set("mlt.interestingTerms", "details");

    MoreLikeThisRequest request //<co id="trc.request"/>
      = new MoreLikeThisRequest(query, content);
    QueryResponse response = request.process(server);

    SolrDocumentList documents = response.getResults(); //<co id="trc.results"/>
    ScoreTag[] rankedTags = rankTags(documents, maxTags);
    return rankedTags;
  }
View Full Code Here

public Iterator<SolrDocument> getCandidates(String title)
    throws SolrServerException {
    String etitle = escape(title); //<co id="co.rm.escape"/>   
    query.setQuery("title:\""+etitle+"\"")//<co id="co.rm.quotes"/>
    QueryResponse response = solr.query(query);
    SolrDocumentList dl = response.getResults();
    return dl.iterator();
}
View Full Code Here

  }
 
  public String topSuggestion(String spelling)
          throws SolrServerException {
    query.setQuery("wordNGram:"+spelling); //<co id="co.dym.field"/>
    QueryResponse response = solr.query(query);
    SolrDocumentList dl = response.getResults();
    Iterator<SolrDocument> di = dl.iterator();
    float maxDistance = 0;
    String suggestion = null;
    while (di.hasNext()) {
      SolrDocument doc = di.next();
View Full Code Here

    this.query(this.getNestedQuery());
    this.query(this.getJsonQuery());
  }

  public void query(final SolrQuery query) throws SolrServerException {
    final QueryResponse rsp = this.server.query(query);
    logger.info("Query: {}", query.getQuery());
    logger.info("Hits: {}", rsp.getResults().getNumFound());
    logger.info("Execution time: {} ms", rsp.getQTime());
    logger.info(rsp.toString());
  }
View Full Code Here

    return response.getNumDocs();
  }

  public String[] search(final SolrQuery query, final String retrievedField)
  throws SolrServerException, IOException {
    final QueryResponse response = this.getServer().query(query);
    final SolrDocumentList docList = response.getResults();

    final int size = docList.size();
    final String docIDs[] = new String[size];
    SolrDocument doc = null;
    for (int i = 0; i < size; i++) {
View Full Code Here

    return docIDs;
  }

  public long search(final SolrQuery query)
  throws SolrServerException, IOException {
    final QueryResponse response = this.getServer().query(query);
    return response.getResults().getNumFound();
  }
View Full Code Here

    query.setQuery("cafe");
    query.setRequestHandler("keyword");
    query.setIncludeScore(true);

    // should match the two documents, with same score
    QueryResponse response = getWrapper().getServer().query(query);
    SolrDocumentList docList = response.getResults();
    assertEquals(2, docList.getNumFound());
    float score1 = (Float) docList.get(0).getFieldValue("score");
    float score2 = (Float) docList.get(1).getFieldValue("score");
    Assert.assertTrue("Score should be identical", score1 == score2);

    // should match the two documents, but should assign different score
    // id2 should receive better score than id1
    query = new SolrQuery();
    query.setQuery("café");
    query.setRequestHandler("keyword");
    query.setIncludeScore(true);

    response = getWrapper().getServer().query(query);
    docList = response.getResults();
    assertEquals(2, docList.getNumFound());
    if (docList.get(0).getFieldValue("url").equals("id1")) {
      score1 = (Float) docList.get(0).getFieldValue("score");
      score2 = (Float) docList.get(1).getFieldValue("score");
    }
View Full Code Here

TOP

Related Classes of org.apache.solr.client.solrj.response.QueryResponse

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.