+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Search Results - No Page Description Shown

Search Results - No Page Description Shown

11 posts, 0 answered
  1. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    01 Nov 2010
    Link to this post

    Anybody have any idea why Sitefinity's search index, or rather search results page, is not showing a description for pages found? It does for News and Blog items, but not for pages.

    We've already got content for the description of the page (in the page properties)

    We've now re-indexed, made sure the pages have descriptions and keywords, restarted IIS, deleted and recreated the search index, nothing's happening. We're still only get an elipsis for the description of pages when searching. Blogs and News search results are fine though.

    Regards,

    Jacques

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Nov 2010
    Link to this post
    Hello J.Hoventer,

    If you search by title does this returns any results? Is this page indexed and what exactly you see when you search for a word from the page description?

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    01 Nov 2010
    Link to this post
    "If you search by title does this returns any results? Is this page indexed and what exactly you see when you search for a word from the page description?"

    1. We're getting correct results in the search results page
    2. The title and link are correct
    3. There's no description shown only an elipsis (...) I even added "hello world" to the description which is not part of the page and it returned the result when I searched for 'hello world', but there's still no description shown on the search results page, only the elipsis

    Regards,
    Jacques
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Nov 2010
    Link to this post
    Hi J.Hoventer,

    I checked the code and the values from the following fields

    "title",  "path",  "keywords", "description" are ignored and replaced by " <strong>...</strong> " in the snippet. This is how the algorithm for page index works.

    You can create your own manager and use it instead of the default one

    namespace Telerik.Search.WebControls
    {
      
        /// <summary>
        /// Summary description for CustomSearchResult
        /// </summary>
        public class CustomSearchResult : SearchResult
        {
            public CustomSearchResult()
            {
            }
            private static string ResolveUrl(string p)
            {
                if (p.StartsWith("/"))
                {   // this is fix for the external pages when page is located in the same site(ex. /Files/Sample.htm)
                    return p;
                }
                CultureInfo culture = null;
                string url = UnresolveIndexPath(p, out culture);
      
                IUrlService langSvc = UrlServices.GetService("LanguageService");
      
                if (langSvc != null)
                    return langSvc.ResolveLanguageUrl(UrlPath.ResolveUrl(url), culture);
                return UrlPath.ResolveUrl(url);
            }
      
            public IList<ResultItem> Search(string searchQuery, string indexName, int startIndex, int max, string mode, bool escapeChars, out int totalItems)
            {
      
                IList<ResultItem> result = new List<ResultItem>();
                string[] fields = GetFields(indexName);
                string indexDirectory = PathUtil.GetIndexPhysicalPath(indexName);
                IndexSearcher searcher = new IndexSearcher(indexDirectory);
      
                QueryParser.Operator searchMode = QueryParser.AND_OPERATOR;
      
                MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
      
                if (!String.IsNullOrEmpty(mode)
                    && mode == "AnyWord")
                {
                    searchMode = QueryParser.OR_OPERATOR;
                }
                parser.SetDefaultOperator(searchMode);
      
                if (escapeChars)
                {
                    searchQuery = QueryParser.Escape(searchQuery);
                }
      
                Query query = searcher.Rewrite(parser.Parse(searchQuery));
                Highlighter highlighter = new Highlighter(new QueryScorer(query));
                Hits hits = searcher.Search(query, Sort.INDEXORDER);
      
                totalItems = hits.Length();
                if (max == 0)
                    max = totalItems;
                else if (startIndex + max > totalItems)
                    max = totalItems;
                else
                    max = startIndex + max;
      
                for (int i = startIndex; i < max; i++)
                {
                    Document doc = hits.Doc(i);
                    ResultItem item = new ResultItem();
                    item.Title = doc.Get("title");
                    item.Url = ResolveUrl(doc.Get("path"));
                    item.Score = hits.Score(i);
      
                    StringBuilder snippet = new StringBuilder();
                    bool lastAppendedIsSeparator = false;
                    for (int k = 0; k < fields.Length; k++)
                    {
                        string field = fields[k];
                         
                        string[] values = doc.GetValues(field);
                        if (values != null && values.Length > 0)
                        {
                            for (int j = 0; j < values.Length; j++)
                            {
                                if (values[j].Length > 0)
                                {
                                    snippet.Append(values[j]);
                                    lastAppendedIsSeparator = false;
                                    if (j < values.Length - 1)
                                    {
                                        snippet.AppendLine(SearchManager.SEARCH_RESULTS_SEPARATOR);
                                        lastAppendedIsSeparator = true;
                                    }
                                }
                            }
                        }
                        if (k < fields.Length - 1 && !lastAppendedIsSeparator)
                        {
                            snippet.AppendLine(SearchManager.SEARCH_RESULTS_SEPARATOR);
                            lastAppendedIsSeparator = true;
                        }
                    }
                    string[] bestFragments = highlighter.GetBestFragments(new StandardAnalyzer(), fields[0], snippet.ToString(), 5);
                    item.Snippet = String.Join(SearchManager.SEARCH_RESULTS_SEPARATOR, bestFragments);
                    item.Snippet.TrimEnd(' ', '.');
                    item.Snippet += SearchManager.SEARCH_RESULTS_SEPARATOR;
                    result.Add(item);
                }
                searcher.Close();
                return result;
            }
      
            private static Dictionary<string, string[]> idxFlds = new Dictionary<string, string[]>();
      
            private static Regex CulterRegex = new Regex(@"^{(\S+)}(.*)", RegexOptions.Compiled);
      
            private static string UnresolveIndexPath(string path, out CultureInfo culture)
            {
                Match match = CulterRegex.Match(path);
                if (match.Success)
                {
                    culture = CultureInfo.GetCultureInfo(match.Groups[1].Value);
                    return match.Groups[2].Value;
                }
                culture = CultureInfo.InvariantCulture;
                return path;
            }
      
            private static string[] GetFields(string provider)
            {
                string[] arr;
                if (!idxFlds.TryGetValue(provider, out arr))
                {
                    List<string> list = new List<string>();
                    foreach (IndexingTypeElement element in ConfigHelper.Handler.Indexers)
                    {
                        BaseIndexer indexer = (BaseIndexer)Activator.CreateInstance(Type.GetType(element.Type)
                                , HttpContext.Current.Server.MapPath(PathUtil.GetIndexVirtualPath(provider))
                                , provider, true);
                        try
                        {
                            foreach (IIndexFieldDetails dtls in indexer.IndexFields)
                                if (!list.Contains(dtls.FieldName))
                                    list.Add(dtls.FieldName);
                        }
                        catch (Exception exc)
                        {
                            string error = exc.Message;
                        }
                        finally
                        {
                            if (indexer != null)
                                indexer.Close();
                        }
                    }
                    arr = list.ToArray();
                    if (list.Count > 0)
                        idxFlds.Add(provider, arr);
                }
                return arr;
            }
        }
    }


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    01 Nov 2010
    Link to this post
    Sorry that answer didn't make sense at all.

    Are you saying that Sitefinity deliberately does that? Doesn't show the description of the page, but instead shows an ellipsis?

    And if you want to get it to show the description I should use the code you just sent?

    Jacques
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Nov 2010
    Link to this post
    Hello J.Hoventer,


    Are you saying that Sitefinity deliberately does that? Doesn't show the description of the page, but instead shows an ellipsis?


    "title",  "path",  "keywords", "description" are ignored and replaced by " <strong>...</strong> " in the snippet. This is how the algorithm for page index works.

    And if you want to get it to show the description I should use the code you just sent?


    You can create your own manager and use it instead of the default one

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    01 Nov 2010
    Link to this post
    Do you have any links that I can perhaps read more about this topic, because your explanation is to brief.
  8. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    02 Nov 2010
    Link to this post
    This still doesn't make any sense to me. Why would Sitefinity include a description section for news and blogs in the search results but not for page results?????

    Look at the attached image where I've highlighted the type of results being found.

    Everything seems to be indexed fine, the results are showing up for each of the pages, but it just doesn't make sense why Sitefinity will not show "A" description for "Indexed PAGES", but will do it for "News" and "Blog" results.

    ?
  9. Seth
    Seth avatar
    2 posts
    Registered:
    24 Sep 2010
    17 Dec 2010
    Link to this post
    J.Hoventer,

    I'm having the same issue. All I get is the ... for the description. Is there a tutorial on creating a custom search results provider to get the description to be more useful?  How did you end up resolving this issue?
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Dec 2010
    Link to this post
    Hello Seth,

    You can take a look at


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Seth
    Seth avatar
    2 posts
    Registered:
    24 Sep 2010
    22 Dec 2010
    Link to this post
    I finally solved the issue. It looks like the sitefinity search engine only indexes a couple fields by default (title, keywords, description). It was not indexing the body of the web pages. I added  the following line to the fieldsInfoProvider.xml and then it started to work.

    <field name="content" weight="1" indexAttribute="" filterTag="div" filterAttributes="id:mainContent" />
Register for webinar
11 posts, 0 answered