Showing posts with label solr. Show all posts
Showing posts with label solr. Show all posts

Thursday 1 June 2023

How to fix Solr downtime issue

Recently I came across a scenario, where solr was down. And because of that Issue - all page which using solr logic related component having issue.


Solr down time issue might occur because of

  • Index got deleted
  • JVM full
  • Solr service stopped
  • Solr server having issue

To avoid such issue in future, most of the projects used base class for Search related logic. Please make sure try-catch mechanism applied.


try

{

using (var context = searchIndex.CreateSearchContext())

{   

  var queryable = context.GetQueryable<S>();

         //search logic   

          var results = queryable.GetResults();

          if (results == null) 

return new S[] { };

  return results.ToList();

}

}

catch (Exception e)

{

Log.Error(e.Message, e, this);

return new S[] { };

}

Friday 30 July 2021

Sitecore control panel local indexes issue - indexes not listing

In this article, we are going to explain about very common issue -  local indexes issue

Few days back, I was also facing same issue that while trying to rebuild one of index from control panel.
There were no index listed on Indexing manager.

As I have attached screenshot



After looking at configs and running services.

Found that core name are not correct (as compare to search engine).
Since we are using solr, so we looked configs as

App_Config/Sitecore/ContentSearch/

~/Sitecore.ContentSearch.Solr.Index.Master.config

~/Sitecore.ContentSearch.Solr.Index.Web.config

~/Sitecore.ContentSearch.Solr.Index.Core.config 

and compared core with Solr admin portal (my instance solr url is : https://localhost:8983)

and correcting corename into configs, indexes started listing.


Hope this will help.

Friday 4 June 2021

Sitecore solr MaxBytesLengthExceededException issue while index rebuild

While triggering index rebuild from Sitecore control Panel, may get below issue as

SolrNet.Exceptions.SolrConnectionException: <?xml version="1.0" encoding="UTF-8"?>

<response>

<lst name="responseHeader">

<int name="status">400</int><int name="QTime">2147</int></lst><lst name="error">

<lst name="metadata"><str name="error-class">org.apache.solr.common.SolrException</str>

<str name="root-error-class">org.apache.lucene.util.BytesRefHash$MaxBytesLengthExceededException</str></lst>

<str name="msg">Exception writing document id sitecore://web/{629c0a43-8382-4aa6-10e8-eb2c0fd5460a}?lang=en&amp;ver=2&amp;ndx=YOUR_INDEXNAME

to the index; possible analysis error: Document contains at least one immense term in field="INDEXEDFIELDNAME" (whose UTF8 encoding is longer than the max length 32766),

all of which were skipped.  Please correct the analyzer to not produce such terms.  The prefix of the first immense term is: '[72, 117, 109, 97, 110, 32, 82, 101, 115, 111, 117, 114, 99, 101, 115, 32, 124, 32, 52, 48, 48, 32, 124, 32, 50, 53, 32, 124, 32, 87]...', 

original message: bytes can be at most 32766 in length; got 58214

Perhaps the document has an indexed string field (solr.StrField) which is too large</str><int name="code">400</int></lst>

</response>

 ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.


Possible Fix:

As I tried to highlight useful information from above log and it seems that we are facing size issue for string Field type in solr.

string Field have max size of 32K (32766) and trying to store 58214 char that is why got exception.

one solution is to change fieldType

From the computed Index configuration file, change returnType for indexField as "Text" after removing "String"

This works for me, hope for you as well.

another solution is to bypass index for this particular file. For that there is a setting in config StoreLocation="true" but I do not feel this will be good approach.

Wednesday 12 May 2021

How to remove all data from Sitecore Solr index ?

Challenge:

Few days back, was working on sitecore solr search related issue that 


From solr portal, was able to retrieve data from index even deleted items (solr index caching issue).

But in the code getting null value for item's properties.


Tried many alternatives to resolve issue (IISRESET, config review, code debug, index rebuild), but no luck.


Approach to fix above issue:

After removing all data from solr index, and then index rebuild issue was resolved.




Steps:

1. From browser open hosted solr portal

2. choose index

3. go to document tab


or copy below URL and hit

1. https://localhost:8987/solr/your_index_name/documents


after this


choose Document Type as Solr command (raw xml or JSON)

then paste query

<delete><query>*:*</query></delete>

and Submit document.

Wednesday 17 February 2021

How to create sitecore custom index ?

With Sitecore, If there are lots of data on the instance where search needed, then Sitecore default index will not be good because it will be time and memory consuming.

In that case - creating custom index will be better approach which contains only searched items.


Let's start with creating solr custom index


Go to your solr installed location by copying sitecore_web_index and rename with sitecore_custom_index [<instancename>_web_index - so don't confused with sitecore]



once copied, then open core.properties and update name property under this directory as below screenshot



after above changes, restart solr service.

Now go to path \App_Config\Sitecore\ContentSearch and copy Sitecore.ContentSearch.Solr.Index.Web.config and rename with Sitecore.ContentSearch.Solr.Index.Custom.onfig as below


once file created open update settings for 
indexname, rootpath, which items wanted to include and exclude in index. as below



Let me know if feel any issue or feedback.