Related Posts question

Topics: Business Logic Layer
May 20, 2009 at 1:40 AM
Edited May 20, 2009 at 1:42 AM

Hi All,

I was wondering if someone could explain the logic behind the related posts functionality --> Search.FindRelatedItems(this.Item) (or point me to the related documentation).
I'm getting some funky results in my dev-environment (i.e. completely unrelated posts) and am trying to understand what's going on.

Thx in advance!
Rgds - Marcus.

 

Coordinator
May 20, 2009 at 2:32 AM

Related Posts uses the built-in Search system to find related posts that contain keywords found in the main post's Title.

So if the Title of a post is "Summer is Here", then the Search system looks for posts containing the words "Summer", "is" or "Here" in the Title and Body of other posts.  Words like "is", "the", "a" etc are actually bypassed.

May 20, 2009 at 3:39 AM

ah - that makes sense now (by that I mean my results) - thx for the quick reply.

That's not going to work for me, though. I don't see the description field showing up anywhere so my idea is to use the title and decription fields for the related posts search. Is that going to break anything?

Thx again!
Rgds - Marcus.

 

Coordinator
May 20, 2009 at 5:09 AM

I don't think that would break anything.

As you may have seen in the code, you could modify the FindRelatedItems function in the Search.cs file (in the BE core).  The RelatedPosts control appears to be the only code throughout BE that currently calls FindRelatedItems.

May 20, 2009 at 9:27 PM

Hey Ben,

thx again for your help.
I added another parameter to the BuildResultSet function (bool includeContent) and worked my way backwards through all the instances where the function is called.

FYI: I was still getting inconsistent results with the Description field. By setting a couple of breakpoints I noticed that the RegEx evaluation wasn't working as I would have expected. My guess was this happened because the Description field wasn't 'sanitized' and lowercased (as I said, a guess - I'm not a RegEx expert), so I added a description property to the struct Entry and another line to the AddItem function to 'cleanse' the Description field.
Don't know if this classifies as a bug, just thought you'd like to know.

I also changed the FindRelatedItems search to use the description field of the post instead of the title. Now I'm getting the results I need :)

I'll have the complete description/edits posted on my blog (as soon as it's ready :) ), in case anyone else is interested.

Rgds - Marcus.