Recommendation to remove current Url from Search Relevancy


Keyvan and team, I'm loving the Graffiti Extras 1.3!
I just finished adding the Search Relevancy chalk extension to my site and I'm digging it. However, one thing I did notice one issue when using long tail keyword searches in Google that deep link directly to a page. If there is only one page in the site that matches that keyword search and it happens to be the one page that the search engine sent the user to then you can end up with something like:
You searched for "some long tail keyword". You might find the following posts useful:
[link]Example Post A Title[/link]
Example Post A Title
content, content, content
Sorry, I should have taken a screenshot before I updated the code, that would explain it better. But hopefully you get my meaning. Basically you end up with a recommendation for only one page, which happens to be the page that you are already on.
I updated the GetRelevantPosts() code with something like this (at about line 37):
                        SearchResultSet<Post> tempPosts = GetRelevantItems(keywords, count);
                        SearchResultSet<Post> posts = new SearchResultSet<Post>();
                        Macros macros = new Macros();
                        foreach (Post post in tempPosts)
                            if (HttpContext.Current != null)
                                string fullUrl = macros.FullUrl(post.Url);
                                string curUrl = HttpContext.Current.Request.Url.ToString();
                                if (curUrl.Contains("Default.aspx"))
                                    curUrl = curUrl.Replace("Default.aspx", "");
                                if (fullUrl != curUrl)
                        if ((posts != null) && (posts.Count > 0))
                            return GetHtmlCode(pattern, keywords, posts);
This assigns all the posts found from GetReleventItems() into tempPosts then loops through each of them and compares the Url to the Url of the current page. If they are the same then it doesn't add it to the list of posts to write out. It only adds it to the lists of posts if the post Url is different from the current page. So if there is only one post and it is the same as the page that you are currently on then it doesn't display the Search Relevancy list.
Feel free to contact me if you have any questions.
Closed Jan 15, 2009 at 8:10 AM by Keyvan


wrote Jan 15, 2009 at 8:10 AM

Resolved with changeset 17997.

wrote Feb 2, 2013 at 1:25 AM

wrote May 14, 2013 at 9:09 PM