Yeah, that can be a pain. Unfortunately there's no official
"programming guide" for instance.

What there is, however, is an extensive suite of unit tests in
/Users/Erick/apache/solrJiras/master/solr/solrj/src/test/org/apache/solr/client/solrj.
>From there it's often a hunt though.

Best,
Erick

On Thu, May 3, 2018 at 8:07 AM, Arturas Mazeika <maze...@gmail.com> wrote:
> Hi Solr Team,
>
> Short question:
>
> How can I systematically explore the solrj functionality/API?
>
> Long question:
>
> I am discovering solrj functionality and I am pretty much impressed what
> solrj can do. What I am less impressed is my knowledge how to find what I
> am looking for. On the positive side, one can relatively quickly find ways
> to insert/delete/update/query docs using solrj (basically using google [1]
> or from [2]). It is a rather simple task to get exposed to some admin
> functionality through [3]. From this on, things are getting more difficult:
> I was able to query for some admin infos by trial and error using this java
> code:
>
> ArrayList<String> urls = new ArrayList<>();
> urls.add(solrUrl);
> CloudSolrClient client = new CloudSolrClient.Builder(urls)
>     .withConnectionTimeout(10000)
>     .withSocketTimeout(60000)
>     .build();
> client.setDefaultCollection("tph");
>
> final SolrRequest request = new CollectionAdminRequest.ClusterStatus();
> final NamedList<Object> response = client.request(request);
> final NamedList<Object> cluster  = (NamedList<Object>)
> response.get("cluster");
> final ArrayList<Object> nodes    = (ArrayList<Object>)
> cluster.get("live_nodes");
> final NamedList<Object> cols       = (NamedList<Object>)
> cluster.get("collections");
> final LinkedHashMap<String, Object> tph = (LinkedHashMap<String, Object>)
> cols.get("tph");
>
> and then looking at what the keys names are, etc. Things are becoming more
> difficult here, as (1) lots of functionality hides behind generic "get"
> methods and (2) The containers that are returned vary from NamedList, to
> anything possible (arraylist, string, hashmap, etc.)
>
> Getting the size of one of the index, e.g., with
>
> ArrayList<String> urls = new ArrayList<>();
> urls.add("http://localhost:8983/solr";);
> CloudSolrClient client = new CloudSolrClient.Builder(urls)
>     .withConnectionTimeout(10000)
>     .withSocketTimeout(60000)
>     .build();
>
> client.setDefaultCollection("trans");
>
> CoreAdminRequest request = new CoreAdminRequest();
> request.setAction(CoreAdminAction.STATUS);
> request.setCoreName("trans_shard2_replica_n4");
>
> request.setIndexInfoNeeded(true);
> CoreAdminResponse resp = request.process(client);
>
> NamedList<Object> coreStatus =
> resp.getCoreStatus("trans_shard2_replica_n4");
> NamedList<Object> indexStats = (NamedList<Object>) coreStatus.get("index");
> System.out.println(indexStats.get("sizeInBytes"));
>
> is even more challenging to learn (how to) as one needs to google deeper
> and deeper [4].
>
> I also looked at the following books for systematic ways to learn solrj:
>
> * Apache Solr 4 Cookbook,
> * Apache Solr Search Patterns
>
> Is there a simple and systematic way to get exposed to solrj and available
> API/functionality?
>
> Cheers,
> Arturas
>
> [1] http://www.baeldung.com/apache-solrj
> [2] https://lucene.apache.org/solr/guide/7_2/using-solrj.html
> [3]
> https://lucene.apache.org/solr/7_2_0/solr-solrj/index.html?org/apache/solr/client/solrj/request/CollectionAdminRequest.ClusterStatus.html
> [4]
> https://www.programcreek.com/java-api-examples/?api=org.apache.solr.client.solrj.request.CoreAdminRequest

Reply via email to