Developer forum

Forum » Development » Dynamicweb.WeightedSearch

Dynamicweb.WeightedSearch

Keerthy Sethupathy
Reply

Greetings!

We have a customer who is using the old Search Module which is using the project Dynamicweb.WeightedSearch Project. 

They have recently been upgraded to 9.8.8, and the search fails because of an Null Reference. 

Would it be possible to add a Null Check in the Method Highlight?

I have to test this added the null check:

private string Highlight(string text, string word)
        {
            if (!string.IsNullOrWhiteSpace(text))
            {
                string[] arrWord = SplitSearchPhrase(word);

                for (int i = 0; i <= arrWord.GetUpperBound(0); i++)
                {
                    word = arrWord[i];

                    if (word.Substring(0, 1) == "+")
                    {
                        word = "\\" + word;
                    }

                    if (word != string.Empty)
                    {
                        string pattern = "(\\b" + Regex.Escape(word) + "\\b)";

                        string replacePattern = "<strong>$1</strong>";
                        Regex regEx = new Regex(pattern, RegexOptions.IgnoreCase);

                        text = regEx.Replace(text, replacePattern);
                    }

                    string encodedPhrase = Searchv1_EncodedSearchPhrases(word);

                    if (encodedPhrase != string.Empty)
                    {
                        if (encodedPhrase.Substring(0, 1) == "+")
                        {
                            encodedPhrase = "\\" + encodedPhrase;
                        }

                        if (!(encodedPhrase == null))
                        {
                            string pattern = "(\\b" + Regex.Escape(encodedPhrase) + "\\b)";

                            string replacePattern = "<strong>$1</strong>";
                            Regex regEx = new Regex(pattern, RegexOptions.IgnoreCase);

                            text = regEx.Replace(text, replacePattern);
                        }
                    }
                }
            }

            return text;
        }

 

 


Replies

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Yes, TFS#81800 with the next release of the nuget package.

BR Nicolai

Votes for this answer: 1
 
Keerthy Sethupathy
Reply

Thanks for the quick response!

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Keerthy

The feature #81800 regarding null check in highlight of weigted search

This is available in Package: Dynamiweb.WeightedSearch version 1.0.22 ,and this has also been implemented in Dynamicweb version 9.9.0 release

You are able to find this releaes in the download section 

https://doc.dynamicweb.com/downloads/releases

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 
Keerthy Sethupathy
Reply

Hi Kristian, 

Thank you!

 

You must be logged in to post in the forum