This project is read-only.

Search does not scan Category

Feb 10, 2014 at 4:31 PM
Hi All!

I have a web site of business cards in which the Posts have no text but contain an image (of the business card). The Posts are categorized.

If I do a search on a category term, the Posts under that category do not appear on the search results.

Does anyone know the algorithm behind the search?

Feb 10, 2014 at 6:35 PM
Edited Feb 10, 2014 at 6:37 PM
Search term is split on space into separate words with each word matched against occurrences in IPublishable title, description, body and optionally any comments. The matches are tallied and weighted in that order. Common words in a stop words list(App_Data) are omitted. Categories are not considered, but the algorithm is easy enough to modify. Note that controls "SearchOnSearch" and "RelatedPosts" also use search. Search.cs in the core.
Feb 10, 2014 at 7:42 PM
Thanks Andy!

I modified Search.cs to search for the categories of each Post. And that fixed my issue. :)

Not sure if rtur would want this feature, but if your blog has lots of categories (I have 55 so far on mine and its growing), it tempts the user to just search on a category string.
         private static List<Result> BuildResultSet(string searchTerm, bool includeComments)
                    #region gerardo
                    if (entry.Item.Categories.Count > 0)
                        foreach (Category cat in entry.Item.Categories)
                            var catMatches = regex.Matches(cat.ToString()).Count;
                            result.Rank += catMatches * 2;