Created
February 19, 2020 15:52
-
-
Save feanz/728a6320660a1f323e6f804ea8ebd56e to your computer and use it in GitHub Desktop.
Add a new language to a solr collection schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All cores use the same index config on remote servers so you should only have to add it to a single core. However locally each core uses a diff config set | |
$solrHost = "localhost:8985" | |
$index = "search_master_index" | |
$ignoreSslErrors = $True | |
$addFieldTypeJson = @' | |
{ | |
"add-field-type": { | |
"name":"text_ko", | |
"class":"solr.TextField", | |
"analyzer":{ | |
"class": "org.apache.lucene.analysis.cjk.CJKAnalyzer", | |
"words": "lang/stopwords_en.txt" | |
} | |
} | |
} | |
'@ | |
$addFieldJson = @' | |
{ | |
"add-dynamic-field": { | |
"name":"*_t_ko", | |
"type":"text_ko", | |
"indexed":true, | |
"stored":true | |
} | |
} | |
'@ | |
if ($ignoreSslErrors) { | |
if (-not("dummy" -as [type])) { | |
add-type -TypeDefinition @" | |
using System; | |
using System.Net; | |
using System.Net.Security; | |
using System.Security.Cryptography.X509Certificates; | |
public static class Dummy { | |
public static bool ReturnTrue(object sender, | |
X509Certificate certificate, | |
X509Chain chain, | |
SslPolicyErrors sslPolicyErrors) { return true; } | |
public static RemoteCertificateValidationCallback GetDelegate() { | |
return new RemoteCertificateValidationCallback(Dummy.ReturnTrue); | |
} | |
} | |
"@ | |
} | |
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = [dummy]::GetDelegate() | |
} | |
Write-Host -ForegroundColor Yellow --- Updating index: $index --- | |
$endpoint = "https://$($solrHost)/solr/$($index)/schema" | |
Write-Host Api Endpoint: $endpoint | |
$response = Invoke-WebRequest -Method POST -Uri $endpoint -Body $addFieldTypeJson -ContentType "application/json" | |
$response = Invoke-WebRequest -Method POST -Uri $endpoint -Body $addFieldJson -ContentType "application/json" | |
Write-Host $response.RawContent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment