schema-api: modifying schema in xml format

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

schema-api: modifying schema in xml format

Arturas Mazeika
Hi solr-users,

is it possible to modify the managed schema using schema api and submit the
commands in XML format? I am able to add a data type using:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field-type": {
  "name":"text_de_ph",
  "class":"solr.TextField",
  "positionIncrementGap":"100",
  "analyzer": {
    "tokenizer": {"class":"solr.StandardTokenizerFactory"},
    "filters": [
      {"class":"solr.LowerCaseFilterFactory"},
      {"class":"solr.StopFilterFactory", "format":"snowball",
"words":"lang/stopwords_de.txt", "ignoreCase":true},
      {"class":"solr.GermanNormalizationFilterFactory"},
      {"class":"solr.GermanLightStemFilterFactory"},
      {"class":"solr.PhoneticFilterFactory", "encoder":"DoubleMetaphone"}
  ]}}
}' http://localhost:8983/solr/tph/schema

so I thought I could submit something like:

curl -X POST -H 'Content-Type: text/xml' --data-binary '
<add-field-type name="text_de_ph" class="solr.TextField"
positionIncrementGap="100">
   <analyzer>
      <tokenizer class="solr.StandardTokenizerFactory"/>
      <filter class="solr.LowerCaseFilterFactory"/>
      <filter class="solr.StopFilterFactory" format="snowball"
words="lang/stopwords_de.txt" ignoreCase="true"/>
      <filter class="solr.GermanNormalizationFilterFactory"/>
      <filter class="solr.GermanLightStemFilterFactory"/>
      <filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone"/>
    </analyzer>
</add-field-type>
' http://localhost:8983/solr/tph/schema

This however failed with the error:

{
  "responseHeader":{
    "status":500,
    "QTime":1},
  "error":{
    "msg":"JSON Parse Error: char=<,position=1 AFTER=' ...

The examples in the documentation (I am using solr 7.2) are all in JSON
format, but does not say explicitly, that one needs to send the updates in
json format only..

https://lucene.apache.org/solr/guide/7_2/schema-api.html#schema-api

Comments?

Cheers,
Arturas
Reply | Threaded
Open this post in threaded view
|

Re: schema-api: modifying schema in xml format

sarowe
Hi Arturas,

The Schema API only understands commands in JSON.  I looked through the ref guide page, and I’m surprised that this isn’t stated directly; I’ll try to fix that.

--
Steve
www.lucidworks.com

> On Apr 18, 2018, at 4:12 AM, Arturas Mazeika <[hidden email]> wrote:
>
> Hi solr-users,
>
> is it possible to modify the managed schema using schema api and submit the
> commands in XML format? I am able to add a data type using:
>
> curl -X POST -H 'Content-type:application/json' --data-binary '{
>  "add-field-type": {
>  "name":"text_de_ph",
>  "class":"solr.TextField",
>  "positionIncrementGap":"100",
>  "analyzer": {
>    "tokenizer": {"class":"solr.StandardTokenizerFactory"},
>    "filters": [
>      {"class":"solr.LowerCaseFilterFactory"},
>      {"class":"solr.StopFilterFactory", "format":"snowball",
> "words":"lang/stopwords_de.txt", "ignoreCase":true},
>      {"class":"solr.GermanNormalizationFilterFactory"},
>      {"class":"solr.GermanLightStemFilterFactory"},
>      {"class":"solr.PhoneticFilterFactory", "encoder":"DoubleMetaphone"}
>  ]}}
> }' http://localhost:8983/solr/tph/schema
>
> so I thought I could submit something like:
>
> curl -X POST -H 'Content-Type: text/xml' --data-binary '
> <add-field-type name="text_de_ph" class="solr.TextField"
> positionIncrementGap="100">
>   <analyzer>
>      <tokenizer class="solr.StandardTokenizerFactory"/>
>      <filter class="solr.LowerCaseFilterFactory"/>
>      <filter class="solr.StopFilterFactory" format="snowball"
> words="lang/stopwords_de.txt" ignoreCase="true"/>
>      <filter class="solr.GermanNormalizationFilterFactory"/>
>      <filter class="solr.GermanLightStemFilterFactory"/>
>      <filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone"/>
>    </analyzer>
> </add-field-type>
> ' http://localhost:8983/solr/tph/schema
>
> This however failed with the error:
>
> {
>  "responseHeader":{
>    "status":500,
>    "QTime":1},
>  "error":{
>    "msg":"JSON Parse Error: char=<,position=1 AFTER=' ...
>
> The examples in the documentation (I am using solr 7.2) are all in JSON
> format, but does not say explicitly, that one needs to send the updates in
> json format only..
>
> https://lucene.apache.org/solr/guide/7_2/schema-api.html#schema-api
>
> Comments?
>
> Cheers,
> Arturas

Reply | Threaded
Open this post in threaded view
|

Re: schema-api: modifying schema in xml format

Arturas Mazeika
Hi Steve,

it is reasonable that schema api understand the commands only JSON. Great
that you'll update the ref guide. Thanks for taking care of it. Nice of you
:-)

Cheers,
Arturas


On Wed, Apr 18, 2018 at 3:27 PM, Steve Rowe <[hidden email]> wrote:

> Hi Arturas,
>
> The Schema API only understands commands in JSON.  I looked through the
> ref guide page, and I’m surprised that this isn’t stated directly; I’ll try
> to fix that.
>
> --
> Steve
> www.lucidworks.com
>
> > On Apr 18, 2018, at 4:12 AM, Arturas Mazeika <[hidden email]> wrote:
> >
> > Hi solr-users,
> >
> > is it possible to modify the managed schema using schema api and submit
> the
> > commands in XML format? I am able to add a data type using:
> >
> > curl -X POST -H 'Content-type:application/json' --data-binary '{
> >  "add-field-type": {
> >  "name":"text_de_ph",
> >  "class":"solr.TextField",
> >  "positionIncrementGap":"100",
> >  "analyzer": {
> >    "tokenizer": {"class":"solr.StandardTokenizerFactory"},
> >    "filters": [
> >      {"class":"solr.LowerCaseFilterFactory"},
> >      {"class":"solr.StopFilterFactory", "format":"snowball",
> > "words":"lang/stopwords_de.txt", "ignoreCase":true},
> >      {"class":"solr.GermanNormalizationFilterFactory"},
> >      {"class":"solr.GermanLightStemFilterFactory"},
> >      {"class":"solr.PhoneticFilterFactory", "encoder":"DoubleMetaphone"}
> >  ]}}
> > }' http://localhost:8983/solr/tph/schema
> >
> > so I thought I could submit something like:
> >
> > curl -X POST -H 'Content-Type: text/xml' --data-binary '
> > <add-field-type name="text_de_ph" class="solr.TextField"
> > positionIncrementGap="100">
> >   <analyzer>
> >      <tokenizer class="solr.StandardTokenizerFactory"/>
> >      <filter class="solr.LowerCaseFilterFactory"/>
> >      <filter class="solr.StopFilterFactory" format="snowball"
> > words="lang/stopwords_de.txt" ignoreCase="true"/>
> >      <filter class="solr.GermanNormalizationFilterFactory"/>
> >      <filter class="solr.GermanLightStemFilterFactory"/>
> >      <filter class="solr.PhoneticFilterFactory"
> encoder="DoubleMetaphone"/>
> >    </analyzer>
> > </add-field-type>
> > ' http://localhost:8983/solr/tph/schema
> >
> > This however failed with the error:
> >
> > {
> >  "responseHeader":{
> >    "status":500,
> >    "QTime":1},
> >  "error":{
> >    "msg":"JSON Parse Error: char=<,position=1 AFTER=' ...
> >
> > The examples in the documentation (I am using solr 7.2) are all in JSON
> > format, but does not say explicitly, that one needs to send the updates
> in
> > json format only..
> >
> > https://lucene.apache.org/solr/guide/7_2/schema-api.html#schema-api
> >
> > Comments?
> >
> > Cheers,
> > Arturas
>
>