5

I created a new custom index named CUSTOM_SERVICES_INDEX using this command:

C:\solr\solr-7.2.1\bin>solr.cmd create -c [custom index name]

(cmd as administrator) then I created the config file named Sitecore.ContentSearch.Solr.Index.Master.<NAME>.config in C:\inetpub\wwwroot\killerbarber.sc\App_Config\Include where killerbarber is root app folder. I did few changes there such as custom index name, field and template Ids that I wanted my index work wit:

click here to see the image

Next step, go to Sitecore > Control Panel > Indexing Manager > Select your new custom index you just created > Build/Rebuild. You will get the next error: undefined field _indexname

click here to see the image

Some workarounds suggest that you have to verify configuration file and validate custome index name, field and template Ids you added on it. All of them are totally fine. Since there is a 400 status code in the error description, I related this issue with some api call and I went to the config file and copied and pasted the URLs that are detailes there:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">

In my case, none of them worked so I was pretty sure that was the root cause but the others file from other index already created have the same values so that was no the root cause at all. So, this get fixed when you Populate Solr Managed Schema (same place than Indexing Manager). Wait, a new error showedup, this one:

click here to see the image

Do not be scared, you will find a lot of fix that required a lot of changes such as change strategy syncMaster to intervalAsyncMaster or copy other index forder that rename it and so on.

This is my fix, go to schema file and change uniqueKey field to any other (_uniqueid in my case). Then, restart Solr Service and, finally, restart IIS. After this you can build the custom index without any problem:

click here to see the image

Question, is there other workaround for this? My fix worked but maybe there is other simplier than this.

Regards

4 Answers 4

5

Did you try populating Solr Managed Schema from Sitecore Control Panel? enter image description here

After creating a custom index in Solr and configuration file in Sitecore, this should be the next step. Once successfully populated, try rebuilding the index.

1
  • This fixed it for me with SXA. Jun 4, 2020 at 21:51
2

If you added a custom core in Solr, take care to include correct conf folder within your core directory. Try copying conf folder from preexisting cores like sitecore_master_index. Once this is done, take care to populate the schema using control panel>Populate the SOLR managed schema option. Once schema is populated successfully, you can try rebuilding the index.

0

This is a great tutorial, but there're some issues that you need to correct before getting an error when your´re going to use the ContentSearchManager.

First and most important, the index name MUST be in lowercase at the moment of creation: custom_services_index

Second, at the moment you want to use your index at your code, do the following to test it:

        public SearchResults<SearchResultItem> GetSearchResultsNonCurated(string searchTerm) {
        var index = ContentSearchManager.GetIndex("custom_services_index");

        using (var context = index.CreateSearchContext())
        {
            var query = context.GetQueryable<SearchResultItem>().Where(x => x.Content.Contains(searchTerm));

            var results = query.GetResults();

            if (results.Hits.Any())
            {
                return results;
            }
        }

        return null;
    }

If you recive Hits, the index is created succesfully, also you can test your index by going to your Solr instance: https://localhost:8989/solr then pick your Index name at the "core selector" and then select "Query" in the options at the left.

Click the "Execute Query" button and then find your fields inside the Json result:

Query results

Regards

0

For anyone who's wondering about this issue in a future, Solr schema (managed-schema file) is different for xDB index than master index for example. If you do a clean installation of Sitecore 10.2 and compare Solr managed-schema file between master and xdb core you notice the Id and other fields are different. So managed-schema file is same for all indexes except xDB solr index.

Your Answer

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

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