Have you checked out the SchemaRequest class in SolrJ? Have not used it myself, 
but looks helpful instead of using GenericSolrRequest for this?
https://solr.apache.org/docs/9_0_0/solrj/org/apache/solr/client/solrj/request/schema/package-summary.html

Jan

> 31. aug. 2022 kl. 00:30 skrev Christopher Schultz 
> <ch...@christopherschultz.net>:
> 
> All,
> 
> I've been working lately on bootstrapping a Solr core from within my 
> application. The source language is Java so I'm using SolrJ and I must say, 
> it's /very/ straightforward to use it for things like performing queries and 
> adding documents to a core, but outside of that, it's very difficult to 
> figure out how anything is supposed to work.
> 
> I have figured out how to query the schema and wade through the morass of 
> nested NamedList<?>, ArrayList<?>, Map.Entry<String,Object>, etc. to actually 
> read the defined fields so I can perform a "diff" against the complete list 
> of expected fields.
> 
> Now I'm trying to do the equivalent of:
> 
> curl --post '{ "add-field":{"name":"first", "type":"text_general", 
> "stored":true}}' [url]
> 
> I can't for the life of me figure out how to actually pass the request entity 
> (aka POST body) to the API, though.
> 
> Here's what I've got:
> 
> req = new GenericSolrRequest(METHOD.POST, "/" + coreName + "/schema", null);
> // req.setRequestContent("{ \"add-field\":{\"name\":\"first\", 
> \"type\":\"text_general\", \"stored\":true}}");
> req.process(solr);
> 
> So, I can already do a GET, but a POST? I tried looking around the API and 
> I'm just not seeing it.
> 
> Any ideas?
> 
> -chris

Reply via email to