2

I am trying to get a custom solr index to work in sitecore 10.2 running in containers.

Config

        <?xml version="1.0" encoding="utf-8" ?>
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" 
    xmlns:role="http://www.sitecore.net/xmlconfig/role/" 
     xmlns:search="http://www.sitecore.net/xmlconfig/search/">
        <sitecore role:require="Standalone or ContentDelivery or 
         ContentManagement" search:require="solr">
        <contentSearch>
            <configuration 
 type="Sitecore.ContentSearch.ContentSearchConfiguration, 
 Sitecore.ContentSearch">
                <indexes hint="list:AddIndex">
                    <index id="sitecore_passportal_web_index" 
type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, 
Sitecore.ContentSearch.SolrProvider">
                        <param desc="name">$(id)</param>
                        <param desc="core">$(id)</param>
                        <param desc="propertyStore" 
ref="contentSearch/indexConfigurations/databasePropertyStore" 
param1="$(id)" />
                    <configuration ref="contentSearch/indexConfigurations/passPortalSolrIndexConfiguration" />
                    <strategies hint="list:AddStrategy">
                        <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/manual" role:require="(ContentManagement and !Indexing) or (ContentDelivery and !Indexing)"/>
                        <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsyncSingleInstance" role:require="Standalone or (ContentManagement and Indexing) or (ContentDelivery and Indexing)" />
                    </strategies>
                    <locations hint="list:AddCrawler">
                        <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                            <Database>web</Database>
                            <Root>/sitecore</Root>
                        </crawler>
                    </locations>
                     
<enableItemLanguageFallback>false</enableItemLanguageFallback>
                     
<enableFieldLanguageFallback>false</enableFieldLanguageFallback>
                    </index>
                </indexes>
            </configuration>
        </contentSearch>
    </sitecore>
</configuration>

I am able to index and see items in solr.

running this code I do not get any results

            using (var searchContext = _passPortalSearchContextProvider.CreateContext())
            {

                IQueryable<BenefitSearchResultItem> results =
                    searchContext.GetQueryable<BenefitSearchResultItem>()
                        //.Where(x => x.Path.StartsWith(siteRootPath))
                        .Where(x => x.TemplateId == Benefit.TEMPLATE_ID)
                        //.Where(x => x.RenewalCodes.Contains(renewalCode))
                        ;

                return results;
            }

So I tried changing the config to using a switch on rebuild solr index

                <index id="sitecore_passportal_web_index" type="Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
                    <param desc="name">$(id)</param>
                    <param desc="core">$(id)</param>
                    <param desc="rebuildcore">$(id)_rebuild</param>

I get the following error when trying to rebuild the index in the sitecore control panel

ManagedPoolThread #4 05:57:11 INFO  Job started: Index_Update_IndexName=sitecore_passportal_web_index
ManagedPoolThread #4 05:57:11 ERROR Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
   at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Jobs.DefaultJob.DoExecute()
   at Sitecore.Abstractions.BaseJob.ThreadEntry(Object state)

Nested Exception

Exception: SolrNet.Exceptions.SolrConnectionException
Message: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404 Not Found</h2>
<table>
<tr><th>URI:</th><td>/solr/sitecore_passportal_web_index_rebuild/update</td></tr>
<tr><th>STATUS:</th><td>404</td></tr>
<tr><th>MESSAGE:</th><td>Not Found</td></tr>
<tr><th>SERVLET:</th><td>default</td></tr>
</table>
5
  • 2
    Does this answer your question? Creating a custom Solr core using solr-init container in docker Aug 4, 2023 at 15:12
  • The custom core is created. The gap is in that he is unable to query what is in Solr. Its 10.2 so wondering if something changed in how Solr queries should be written.
    – Kode
    Aug 4, 2023 at 15:31
  • Please add _passPortalSearchContextProvider to your question? Or confirm it is calling ContentSearchProvider.getindex("your-index-name"). Also when you run the code shown above, there should be a corresponding log entry generated in search logs. Do you see this? If so, try navigating to SOLR dashboard => query and pasting in the query (after the ?q=) in the url. Alter to find correct query. Finally, the switch on rebuild error you are seeing is because you have not created the rebuild core. To do this, copy the original core, delete data, then rename the core in core.properties file. Aug 4, 2023 at 19:39
  • Ken - When you switched to index on rebuild, did you create an alternate index for the rebuild? So, in total, you should have 2 indexes - 1 for the main and 1 for rebuild. From your exception, it looks like you haven't created the index for rebuild. Please create a rebuild index and try to index it from Sitecore. Aug 7, 2023 at 14:53
  • Got it to work. Wound up being how I created the new solr indexes. The instructions provided by @MichaelWest worked
    – Ken Tucker
    Aug 14, 2023 at 15:23

0

Your Answer

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

Browse other questions tagged or ask your own question.