Example usage for org.apache.solr.client.solrj.response QueryResponse getLimitingFacets

List of usage examples for org.apache.solr.client.solrj.response QueryResponse getLimitingFacets

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj.response QueryResponse getLimitingFacets.

Prototype

public List<FacetField> getLimitingFacets() 

Source Link

Usage

From source file:it.seralf.solrbook.client.java.SolrJQueryExample.java

License:Apache License

public static void main(String[] args) throws Exception {

    HttpSolrServer server = new HttpSolrServer("http://localhost:8983/solr/arts");

    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("uri", "http://TEST/Leonardo_da_Vinci");
    doc.addField("artist", "Leonardo Da Vinci");
    doc.addField("city", "Vinci");
    doc.addField("note", "document updated");
    server.add(doc);/*from  w w w .j a  v a  2 s.co m*/
    server.commit();

    SolrQuery solrQuery = new SolrQuery().setQuery("vermeer~0.5").setFacet(true).setFacetMinCount(1)
            .setFacetLimit(8).addFacetField("museum_entity").addFacetField("city").setHighlight(true)
            .setHighlightSnippets(3).setParam("hl.fl", "artist");

    System.out.printf("QUERY: %s/%s\n\n", server.getBaseURL(), solrQuery);

    QueryResponse rsp = server.query(solrQuery);

    System.out.println("#### DOCs");
    for (SolrDocument d : rsp.getResults()) {
        System.out.println(d);
    }

    System.out.println("#### facets");
    for (Object e : rsp.getLimitingFacets()) {
        System.out.println(e);
    }

    System.out.println("#### highligths");
    for (Entry<?, ?> e : rsp.getHighlighting().entrySet()) {
        System.out.println(e);
    }

    server.shutdown();
}