2

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

1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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