I solved the PUT issue using a post ( with adding of more than one field) :

             ContentStreamUpdateRequest contentStreamUpdateRequest =
>                 new ContentStreamUpdateRequest(
> SCHEMA_SOLR_FIELDS_ENDPOINT);
>             SolrServer solrServer = this.getCore( core );
>             contentStreamUpdateRequest.addContentStream(new
> ContentStreamBase.ByteArrayStream(jsonFields.getBytes(),"data-binary"));
>             UpdateResponse process = contentStreamUpdateRequest.process(
> solrServer );


The EmbeddedSolrServer is still a problem.

Cheers


2014-07-09 15:55 GMT+01:00 Alessandro Benedetti <benedetti.ale...@gmail.com>
:

> mmm wondering how to pass the payload for the PUT using that structure
> with SolrQuery...
>
>
> 2014-07-09 15:42 GMT+01:00 Alessandro Benedetti <
> benedetti.ale...@gmail.com>:
>
> Thank's Elaine !
>> Worked for the GET Method !
>> I will test soon with the PUT method :)
>>
>> One strange thing is that is working with a real Solr Instance but not
>> with an Embedded SolrServer ...
>> probably it's matter of dependencies, I let you know...
>>
>> Many thanks
>>
>> Cheers
>>
>>
>> 2014-07-08 21:59 GMT+01:00 Cario, Elaine <elaine.ca...@wolterskluwer.com>
>> :
>>
>> Alessandro,
>>>
>>> I just got this to work myself:
>>>
>>>         public static final String DEFINED_FIELDS_API = "/schema/fields";
>>>         public static final String DYNAMIC_FIELDS_API =
>>> "/schema/dynamicfields";
>>> ...
>>>         // just get a connection to Solr as usual (the factory is mine -
>>> it will use CloudSolrServer or HttpSolrServer depending on if we're using
>>> SolrCloud or not)
>>>         SolrClient client =
>>> SolrClientFactory.getSolrClientInstance(CLOUD_ENABLED);
>>>         SolrServer solrConn = client.getConnection(SOLR_URL, collection);
>>>
>>>         SolrQuery query = new SolrQuery();
>>>         if (dynamicFields)
>>>                 query.setRequestHandler(DYNAMIC_FIELDS_API);
>>>         else
>>>                 query.setRequestHandler(DEFINED_FIELDS_API);
>>>         query.setParam("showDefaults", true);
>>>
>>>         QueryResponse response = solrConn.query(query)
>>>
>>> Then you've got to parse the response using NamedList etc.etc.
>>>
>>> -----Original Message-----
>>> From: Alessandro Benedetti [mailto:benedetti.ale...@gmail.com]
>>> Sent: Tuesday, July 08, 2014 5:54 AM
>>> To: solr-user@lucene.apache.org
>>> Subject: [Solr Schema API] SolrJ Access
>>>
>>> Hi guys,
>>> wondering if there is any proper way to access Schema API via Solrj.
>>>
>>> Of course is possible to reach them in Java with a specific Http
>>> Request, but in this way, using SolrCloud for example we become coupled to
>>> one specific instance ( and we don't want) .
>>>
>>> Code Example :
>>>
>>>             HttpResponse httpResponse;
>>> >             String url=this.solrBase+"/"+core+
>>> > SCHEMA_SOLR_FIELDS_ENDPOINT
>>> > +fieldName;
>>> >             HttpPut httpPut = new HttpPut(url);
>>> >             StringEntity entity = new StringEntity(
>>> >                     "{\"type\":\"text_general\",\"stored\":\"true\"}" ,
>>> >                     ContentType.APPLICATION_JSON);
>>> >              httpPut.setEntity( entity );
>>> >              HttpClient client=new DefaultHttpClient();
>>> >              response = client.execute(httpPut);
>>>
>>>
>>> Any suggestion ?
>>> In my opinion should be interesting to have some auxiliary method in
>>> SolrServer if it's not there yet.
>>>
>>> Cheers
>>>
>>> --
>>> --------------------------
>>>
>>> Benedetti Alessandro
>>> Visiting card : http://about.me/alessandro_benedetti
>>>
>>> "Tyger, tyger burning bright
>>> In the forests of the night,
>>> What immortal hand or eye
>>> Could frame thy fearful symmetry?"
>>>
>>> William Blake - Songs of Experience -1794 England
>>>
>>
>>
>>
>> --
>> --------------------------
>>
>> Benedetti Alessandro
>> Visiting card : http://about.me/alessandro_benedetti
>>
>> "Tyger, tyger burning bright
>> In the forests of the night,
>> What immortal hand or eye
>> Could frame thy fearful symmetry?"
>>
>> William Blake - Songs of Experience -1794 England
>>
>
>
>
> --
> --------------------------
>
> Benedetti Alessandro
> Visiting card : http://about.me/alessandro_benedetti
>
> "Tyger, tyger burning bright
> In the forests of the night,
> What immortal hand or eye
> Could frame thy fearful symmetry?"
>
> William Blake - Songs of Experience -1794 England
>



-- 
--------------------------

Benedetti Alessandro
Visiting card : http://about.me/alessandro_benedetti

"Tyger, tyger burning bright
In the forests of the night,
What immortal hand or eye
Could frame thy fearful symmetry?"

William Blake - Songs of Experience -1794 England

Reply via email to