You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Arturas Mazeika <ma...@gmail.com> on 2018/04/18 08:12:17 UTC

schema-api: modifying schema in xml format

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

Re: schema-api: modifying schema in xml format

Posted by Arturas Mazeika <ma...@gmail.com>.
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 <sa...@gmail.com> 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 <ma...@gmail.com> 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
>
>

Re: schema-api: modifying schema in xml format

Posted by Steve Rowe <sa...@gmail.com>.
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 <ma...@gmail.com> 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