Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created June 9, 2019 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/4f861324ee0bdc169f838cab517ba8cf to your computer and use it in GitHub Desktop.
Save pandanote-info/4f861324ee0bdc169f838cab517ba8cf to your computer and use it in GitHub Desktop.
Apache Solr 8の動作確認用にテキストファイルをインポートするために必要な設定をApache Solrに対して行うためのシェルスクリプト。
#!/bin/sh
CORE_NAME=pandanote.info
if [ "$1" != "" ]; then
CORE_NAME=$1
fi
curl -X POST -H 'Content-type:application/json' --data-binary '{
"replace-field-type":{
"name":"text_ja",
"class":"solr.TextField",
"autoGeneratePhraseQueries":"false",
"positionIncrementGap":"100",
"analyzer":{
"charFilter": {
"class":"solr.ICUNormalizer2CharFilterFactory",
"name":"nfkc"},
"tokenizer": {
"class":"solr.JapaneseTokenizerFactory",
"mode":"search",
"userDictionary":"lang/userdict_ja.txt"},
"filter": {
"class":"solr.SynonymFilterFactory",
"synonyms":"synonyms.txt",
"ignoreCase":"true",
"expand":"true"},
"filter": {
"class":"solr.JapaneseBaseFormFilterFactory"},
"filter": {
"class":"solr.JapanesePartOfSpeechStopFilterFactory",
"tags":"lang/stoptags_ja.txt"},
"filter": {
"class":"solr.CJKWidthFilterFactory"},
"filter": {
"class":"solr.StopFilterFactory",
"words":"lang/stopwords_ja.txt",
"ignoreCase":"true"},
"filter": {
"class":"solr.JapaneseKatakanaStemFilterFactory",
"minimumLength":"4"},
"filter": {
"class": "solr.LowerCaseFilterFactory"}}}}' http://localhost:8983/api/cores/${CORE_NAME}/schema
curl -X POST -H 'Content-type:application/json' --data-binary '{
"add-field":{
"name":"search",
"type":"text_ja",
"multiValued":"true",
"indexed":"true",
"required":"false",
"stored":"true",
"termVectors":"true"
"termPositions":"true",
"termOffsets":"true"
}}' http://localhost:8983/api/cores/${CORE_NAME}/schema
curl -X POST -H 'Content-type:application/json' --data-binary '{
"add-copy-field":{
"source":"_text_",
"dest":"search"
}}' http://localhost:8983/api/cores/${CORE_NAME}/schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment