Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EA49011334 for ; Tue, 8 Jul 2014 21:00:18 +0000 (UTC) Received: (qmail 99499 invoked by uid 500); 8 Jul 2014 21:00:15 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 99436 invoked by uid 500); 8 Jul 2014 21:00:15 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 99425 invoked by uid 99); 8 Jul 2014 21:00:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2014 21:00:14 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [68.232.131.93] (HELO esa1.wolterskluwer.iphmx.com) (68.232.131.93) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2014 21:00:09 +0000 X-IronPort-AV: E=Sophos;i="5.01,627,1400043600"; d="scan'208";a="59590493" Received: from mx4.wkglobal.com ([160.109.106.96]) by esa1.wolterskluwer.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 08 Jul 2014 15:59:45 -0500 Received: from WKUTLMSGHMCP03.wkglobal.com (wkutlmsghmcp03.wkglobal.com [10.204.48.109]) by mx4.wkglobal.com (8.13.8/8.13.8) with ESMTP id s68KxgQp001582 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Tue, 8 Jul 2014 15:59:42 -0500 Received: from WKUTLMSGHMCP01.wkglobal.com ([fe80::4cc9:3cc1:e872:7b1d]) by WKUTLMSGHMCP03.wkglobal.com ([fe80::3d0e:72ff:ad60:d4fc%23]) with mapi id 14.03.0174.001; Tue, 8 Jul 2014 15:59:43 -0500 From: "Cario, Elaine" To: "solr-user@lucene.apache.org" Subject: RE: [Solr Schema API] SolrJ Access Thread-Topic: [Solr Schema API] SolrJ Access Thread-Index: AQHPmpKYIPs8Zn2CnUKceiuRFSSvBJuWqHbQ Date: Tue, 8 Jul 2014 20:59:42 +0000 Message-ID: <8B133F311D05A545B36902437D8097620EC05CF9@WKUTLMSGHMCP01.wkglobal.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.204.192.69] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Alessandro, I just got this to work myself: public static final String DEFINED_FIELDS_API =3D "/schema/fields"; public static final String DYNAMIC_FIELDS_API =3D "/schema/dynamicfields"; ... // just get a connection to Solr as usual (the factory is mine - it will u= se CloudSolrServer or HttpSolrServer depending on if we're using SolrCloud = or not) SolrClient client =3D SolrClientFactory.getSolrClientInstance(CLOUD_ENABLE= D); SolrServer solrConn =3D client.getConnection(SOLR_URL, collection); =09 SolrQuery query =3D new SolrQuery(); if (dynamicFields) query.setRequestHandler(DYNAMIC_FIELDS_API); else query.setRequestHandler(DEFINED_FIELDS_API); query.setParam("showDefaults", true); QueryResponse response =3D solrConn.query(query) Then you've got to parse the response using NamedList etc.etc. -----Original Message----- From: Alessandro Benedetti [mailto:benedetti.alex85@gmail.com]=20 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, b= ut in this way, using SolrCloud for example we become coupled to one specif= ic instance ( and we don't want) . Code Example : HttpResponse httpResponse; > String url=3Dthis.solrBase+"/"+core+=20 > SCHEMA_SOLR_FIELDS_ENDPOINT > +fieldName; > HttpPut httpPut =3D new HttpPut(url); > StringEntity entity =3D new StringEntity( > "{\"type\":\"text_general\",\"stored\":\"true\"}" , > ContentType.APPLICATION_JSON); > httpPut.setEntity( entity ); > HttpClient client=3Dnew DefaultHttpClient(); > response =3D client.execute(httpPut); Any suggestion ? In my opinion should be interesting to have some auxiliary method in SolrSe= rver 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