0

I'm trying to Automate some of the Setup of Solr Core's for Sitecore 10.3 and everything works fine - apart from one thing which is that there is a requirement to set update.autoCreateFields=false in the core.properties file like so and I can't seem to get this to work via the API:

name=[CORE_NAME]
config=solrconfig.xml
update.autoCreateFields=false
dataDir=data

I tried setting it when creating the core but it seems to be ignored:

function Create-SolrCore($solrBaseUrl, $coreName) {
    $restUrl = "{0}/admin/cores?action=CREATE&name={1}&configSet={2}&dataDir=data&update.autoCreateFields=true" -f $solrBaseUrl, $coreName, $SolrConfigSetName
    Write-Host "Creating Solr core - $coreName : $restUrl ..."
    $result = Invoke-WebRequest $restUrl -Method GET -UseBasicParsing
    Write-Host "Created Solr core: $coreName. - $($result)"
}

I also tried like so using the set-user-property request but it still seems to have no affect:

 function Set-CoreProperty($solrBaseUrl, $coreName) {
    $restUrl = "{0}/collection/config" -f $solrBaseUrl, $coreName
    Write-Host "Setting Property for core - $coreName : $restUrl ..."
    $result = Invoke-WebRequest $restUrl -Method POST -ContentType "application/json" -Body "{`"set-user-property`":{`"update.autoCreateFields`":true}}"
    Write-Host "Property set for Solr core: $coreName. - $($result)"
 }

Any input on how best to go about automating this would be appreciated.

I guess if it's not possible via the APIs I could set this in the solr.config file that is used by all my Core's and that should work? but I'd rather not have to make manual updates:

<!-- The update.autoCreateFields property can be turned to false to disable schemaless mode -->
<updateRequestProcessorChain name="add-unknown-fields-to-the-schema" default="${update.autoCreateFields:true}"
       processor="uuid,remove-blank,field-name-mutating,parse-boolean,parse-long,parse-double,parse-date,add-schema-fields">
    <processor class="solr.LogUpdateProcessorFactory"/>
    <processor class="solr.DistributedUpdateProcessorFactory"/>
    <processor class="solr.RunUpdateProcessorFactory"/>
</updateRequestProcessorChain>

More info on the steps here: https://doc.sitecore.com/xp/en/developers/103/platform-administration-and-architecture/walkthrough--setting-up-solr.html

1 Answer 1

0

When you utilize the API to set a user property, a configoverlay.json file is generated within the conf folder for the designated Solr collection. This file is responsible for housing and managing the property's value, without any alterations to the main core.properties file.

To confirm whether the property has been successfully updated, you can check the configoverlay.json file directly to view its content. Alternatively, you can access the following endpoint:

https://<host>:<post>/solr/<collection>/config/overlay
3
  • Thanks @surya I'll check that and see what the outcome is. I wasn't aware of this overlay approach. Sep 12, 2023 at 14:56
  • @AdamSeabridge did you check it? Sep 29, 2023 at 21:09
  • Hey, sorry I didn't as we decided to approach this in a different way on this project. When I get chance I will come back to this and test this approach though. Oct 13, 2023 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.