Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change 
notification.

The following page has been changed by NoblePaul:
http://wiki.apache.org/solr/Solrj

The comment on the change is:
faceted query example

------------------------------------------------------------------------------
  server.setParser(new XMLResponseParser());
  }}}
  == Changing other Connection Settings ==
- If you need to control other connection settings, you can cast the server to 
!CommonsHttpSolrServer.
+ !CommonsHttpSolrServer allows setting connection properties.
  
  {{{
    String url = "http://localhost:8983/solr";
-   SolrServer server = new CommonsHttpSolrServer( url );
+   CommonsHttpSolrServer server = new CommonsHttpSolrServer( url );
-   ((CommonsHttpSolrServer)server).setConnectionTimeout(100);
+   server.setConnectionTimeout(100);
-   ((CommonsHttpSolrServer)server).setDefaultMaxConnectionsPerHost(100);
+   server.setDefaultMaxConnectionsPerHost(100);
-   ((CommonsHttpSolrServer)server).setMaxTotalConnections(100);
+   server.setMaxTotalConnections(100);
  }}} 
  
  
@@ -167, +167 @@

  {{{
     List<Item> beans = rsp.getBeans(Item.class);
  }}}
+ === Advanced usage ===
+ SolrJ provides a APIs to create queries instead of hand coding the query . 
See the example of a faceted query.
+ {{{
+   SolrServer server = getSolrServer();
+   SolrQuery sq = new  SolrQuery();
+   sq.setQuery(query);
+   sq.setFacet(true);
+   sq.setFacetMinCount(1);
+   sq.setFacetLimit(8);
+   sq.addFacetField("category");
+   sq.addFacetField("inStock");  
+   QueryResponse rsp = server.query(solrQuery);
+ }}}
  

Reply via email to