It worked! Thanks Mr. Rafalovitch. I just removed “type”: “query”.. keys from 
the json, and used indexAnalyzer and queryAnalyzer in place of analyzer json 
node.

Sent from Mail for Windows 10

From: Alexandre Rafalovitch
Sent: 03 March 2021 01:19
To: solr-user
Subject: Re: Schema API specifying different analysers for query and index

RefGuide gives this for Adding, I would hope the Replace would be similar:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field-type":{
     "name":"myNewTextField",
     "class":"solr.TextField",
     "indexAnalyzer":{
        "tokenizer":{
           "class":"solr.PathHierarchyTokenizerFactory",
           "delimiter":"/" }},
     "queryAnalyzer":{
        "tokenizer":{
           "class":"solr.KeywordTokenizerFactory" }}}
}' http://localhost:8983/solr/gettingstarted/schema

So, indexAnalyzer/queryAnalyzer, rather than array:
https://lucene.apache.org/solr/guide/8_8/schema-api.html#add-a-new-field-type

Hope this works,
    Alex.
P.s. Also check whether you are using matching API and V1/V2 end point.

On Tue, 2 Mar 2021 at 15:25, ufuk yılmaz <uyil...@vivaldi.net.invalid> wrote:
>
> Hello,
>
> I’m trying to change a field’s query analysers. The following works but it 
> replaces both index and query type analysers:
>
> {
>     "replace-field-type": {
>         "name": "string_ci",
>         "class": "solr.TextField",
>         "sortMissingLast": true,
>         "omitNorms": true,
>         "stored": true,
>         "docValues": false,
>         "analyzer": {
>             "type": "query",
>             "tokenizer": {
>                 "class": "solr.StandardTokenizerFactory"
>             },
>             "filters": [
>                 {
>                     "class": "solr.LowerCaseFilterFactory"
>                 }
>             ]
>         }
>     }
> }
>
> I tried to change analyzer field to analyzers, to specify different analysers 
> for query and index, but it gave error:
>
> {
>     "replace-field-type": {
>         "name": "string_ci",
>         "class": "solr.TextField",
>         "sortMissingLast": true,
>         "omitNorms": true,
>         "stored": true,
>         "docValues": false,
>         "analyzers": [{
>             "type": "query",
>             "tokenizer": {
>                 "class": "solr.StandardTokenizerFactory"
>             },
>             "filters": [
>                 {
>                     "class": "solr.LowerCaseFilterFactory"
>                 }
>             ]
>         },{
>             "type": "index",
>             "tokenizer": {
>                 "class": "solr.KeywordTokenizerFactory"
>             },
>             "filters": [
>                 {
>                     "class": "solr.LowerCaseFilterFactory"
>                 }
>             ]
>         }]
>     }
> }
>
> "errorMessages":["Plugin init failure for [schema.xml]....
> "msg":"error processing commands",...
>
> How can I specify different analyzers for query and index type when using 
> schema api?
>
> Sent from Mail for Windows 10
>

Reply via email to