简体   繁体   中英

Solr: change managed schema to schema and add new field in WINDOWS when using DIH

I am trying to learn and create SOLR search engine for text search.

My initial step is to load a table of content from SQL to Solr. I have imported data using data import handler but Solr loaded only id field. Later I realised that the managed schema does not work with DIH . So I am currently switching form managed schema to classic schema.

One of the step that Solr learning material asks me to do is add new field through schema API and it has given below commands for UNIX. I am not sure its equivalent windows command. Since POST command cannot be used in windows.

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field":{
     "name":"sell-by",
     "type":"tdate",
     "stored":true 
  }
}' http://localhost:8983/solr/gettingstarted/schema

Below is the command I used which failed,

curl -X  java -jar example\exampledocs\post.jar  -H 'Content-type:application/json' --data-binary '{
  "add-field":{
    "name":"FIN", 
    "type":"int", 
      "stored":true 
  }
}' http://localhost:8983/solr/#/firstcore/schema

Your advice or help would be much appreciated. I am stuck here for long time. I could not find how to add fields in windows. Any advice would be very much appreciated.

There are some problem with your request parameter.

  • First of all type integer not available by default if you are implemented it then it is fine.
  • You have not specified request HTTP method so it takes as GET while it require POST . I think you removed it after try requesting it by POST but it may end-up with Method Not Supported .
  • Above problem Method Not Supported is not because of POST method, it is because your URL was wrong, It should be http://localhost:8983/solr/firstcore/schema .

These are the problem which I find from your provided data and here is my example of adding field.

And Yes I am using Postman as a rest client

使用邮差在solr中添加新字段的步骤

After success operation you will see you schema file of you collection will updated in Files menu on SOLR WebApp:

To check that:

  • Go to the WebApp
  • Select Collection
  • Click on Files
  • Go to your chema file.
  • Find your added field.

SOLR WebApp菜单

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM