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

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


          .getParams().getSortField(), searchUID);
      solrQuery.setSortField(query.getParams().getSortField(), query
          .getParams().isReverse() ? ORDER.asc : ORDER.desc);
    }

    QueryResponse response;
    try {
      response = solr.query(solrQuery);
    } catch (final SolrServerException e) {
      throw SolrWriter.makeIOException(e);
    }

    final SolrDocumentList docList = response.getResults();

    final Hit[] hitArr = new Hit[docList.size()];
    for (int i = 0; i < hitArr.length; i++) {
      final SolrDocument solrDoc = docList.get(i);
View Full Code Here


    query.getParams().setReverse(reverse);
    return search(query);
  }

  public HitDetails getDetails(Hit hit) throws IOException {
    QueryResponse response;
    try {
      response = solr.query(new SolrQuery(searchUID + ":\"" + hit.getUniqueKey() + "\""));
    } catch (final SolrServerException e) {
      throw SolrWriter.makeIOException(e);
    }

    final SolrDocumentList docList = response.getResults();
    if (docList.getNumFound() == 0) {
      return null;
    }

    return buildDetails(docList.get(0));
View Full Code Here

      buf.append(hit.getUniqueKey());
      buf.append("\"");
    }
    buf.append(")");

    QueryResponse response;
    try {
      response = solr.query(new SolrQuery(buf.toString()));
    } catch (final SolrServerException e) {
      throw SolrWriter.makeIOException(e);
    }

    final SolrDocumentList docList = response.getResults();
    if (docList.size() < hits.length) {
      throw new RuntimeException("Missing hit details! Found: " +
                                 docList.size() + ", expecting: " +
                                 hits.length);
    }
View Full Code Here

    @Override
    public Cursor query(Filter filter, NodeState root) {
        Cursor cursor;
        try {
            SolrQuery query = getQuery(filter);
            QueryResponse queryResponse = solrServer.query(query);
            cursor = new SolrCursor(queryResponse);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return cursor;
View Full Code Here

                setProperty("text", "hats tattoos hit hot");
        r.commit();

        SolrQuery query = new SolrQuery();
        query.setQuery("*:*");
        QueryResponse queryResponse = server.query(query);
        assertTrue("no documents were indexed", queryResponse.getResults().size() > 0);
    }
View Full Code Here

        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "MA147LL/A", 1.0f);
        String docAsXml = ClientUtils.toXML(doc);
        directXmlRoute.sendBody(docAsXml);

        QueryResponse response = executeSolrQuery("id:MA147LL/A");
        assertEquals(0, response.getStatus());
        assertEquals(1, response.getResults().getNumFound());
    }
View Full Code Here

    @Test
    public void endToEndIndexXMLDocuments() throws Exception {
        xmlRoute.sendBody(new File("src/test/resources/data/books.xml"));

        // Check things were indexed.
        QueryResponse response = executeSolrQuery("*:*");

        assertEquals(0, response.getStatus());
        assertEquals(4, response.getResults().getNumFound());

        // Check fields were indexed correctly.
        response = executeSolrQuery("title:Learning XML");

        SolrDocument doc = response.getResults().get(0);
        assertEquals("Learning XML", doc.getFieldValue("id"));
        assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
    }
View Full Code Here

    @Test
    public void endToEndIndexXMLDocumentsStreaming() throws Exception {
        xmlRouteStreaming.sendBody(new File("src/test/resources/data/books.xml"));

        // Check things were indexed.
        QueryResponse response = executeSolrQuery("*:*");

        assertEquals(0, response.getStatus());
        assertEquals(4, response.getResults().getNumFound());

        // Check fields were indexed correctly.
        response = executeSolrQuery("title:Learning XML");

        SolrDocument doc = response.getResults().get(0);
        assertEquals("Learning XML", doc.getFieldValue("id"));
        assertEquals(Arrays.asList("Web", "Technology", "Computers"), doc.getFieldValue("cat"));
    }
View Full Code Here

    @DirtiesContext
    @Test
    public void endToEndIndexPDFDocument() throws Exception {
        pdfRoute.sendBody(new File("src/test/resources/data/tutorial.pdf"));

        QueryResponse response = executeSolrQuery("*:*");

        assertEquals(0, response.getStatus());
        assertEquals(1, response.getResults().getNumFound());

        SolrDocument doc = response.getResults().get(0);
        assertEquals("Solr", doc.getFieldValue("subject"));
        assertEquals("tutorial.pdf", doc.getFieldValue("id"));
        assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
    }
View Full Code Here

    @DirtiesContext
    @Test
    public void endToEndIndexPDFDocumentStreaming() throws Exception {
        pdfRouteStreaming.sendBody(new File("src/test/resources/data/tutorial.pdf"));

        QueryResponse response = executeSolrQuery("*:*");

        assertEquals(0, response.getStatus());
        assertEquals(1, response.getResults().getNumFound());

        SolrDocument doc = response.getResults().get(0);
        assertEquals("Solr", doc.getFieldValue("subject"));
        assertEquals("tutorial.pdf", doc.getFieldValue("id"));
        assertEquals(Arrays.asList("application/pdf"), doc.getFieldValue("content_type"));
    }
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.