Mono Support Search functionality 

Viewed 25437 time(s), 4 post(s), 11/15/2013 12:45:52 AM - by mmorozov
11/15/2013 12:45:52 AM
95 Reputation 10 Total posts

In the current search implementation, I often get a timeout even with Full-Text search configured.  And it looks like the search scope is "All discussions". Is there a way to limit the search scope to a specific discussion board or even a specific topic?

Another interesting feature is to search only in the posts of people who I list as friends. When the community grows, the search results return a lot of noise. 

1
11/19/2013 11:19:15 AM
15993 Reputation 2214 Total posts

Hi,

you can do the following in order to accomplish what you need:

1. You will need to add a separate search WebPart (MonoXSearchBoxWithFilter.ascx - "Filtered site search") and setup the search with only "DiscussionSearchProvider" like this:

<MonoX:Search ID="search1" runat="server" Title='<%$ Code: PageResources.Title_SearchResults %>'>
    <SearchProviderItems>                               
        <Search:SearchProviderItem Name="DiscussionSearchProviderOnlyBoard" Template="Default"></Search:SearchProviderItem>
    </SearchProviderItems>
</MonoX:Search>
2. "Is there a way to limit the search scope to a specific discussion board or even a specific topic? " In order to filter out only Boards or Topics or Messages you can register another discussion search provider of the same type in the web.config but with different setup. You will need to set it similar to this:

<add name="DiscussionSearchProviderOnlyBoard" type="MonoSoftware.MonoX.SearchEngine.Providers.DiscussionSearchProvider, MonoX" DiscussionDescriptionLength="255" BoldSearchPhrases="true" FullTextSearch="false" MaxNoOfResults="100" SearchBoards="true" SearchTopics="false" SearchMessages="false"/>
DiscussionSearchProvider.SearchBoards
DiscussionSearchProvider.SearchTopics
DiscussionSearchProvider.SearchMessages

3. To filter by specific board you will need to inherit the DiscussionSearchProvider and override a few methods

/// <summary>
/// Initialize message filter.
/// </summary>
/// <param name="filter">Filter.</param>
protected virtual void InitMessageFilter(RelationPredicateBucket filter)
 
/// <summary>
/// Initialize topic filter.
/// </summary>
/// <param name="filter">Filter.</param>
protected virtual void InitTopicFilter(RelationPredicateBucket filter)
 
/// <summary>
/// Initialize board filter.
/// </summary>
/// <param name="filter">Filter.</param>
protected virtual void InitBoardFilter(RelationPredicateBucket filter)
and you will need to add the following line of code to filter:

/// <summary>
/// Initialize board filter.
/// </summary>
/// <param name="filter">Filter.</param>
protected override void InitBoardFilter(RelationPredicateBucket filter)
{
    base.InitBoardFilter(filter);
    if (UrlParams.EntityId.HasValue)
        filter.PredicateExpression.Add(SnDiscussionBoardFields.Id == UrlParams.EntityId.Value);
}
and do the same for Topics and Messages if you want to filter by them.

Let us know if you need more help with this.

Regards

2
9/2/2015 8:11:33 PM
215 Reputation 29 Total posts

Speaking of search engines; is there a tutorial or a walkthrough for adding additional search Providers ?

Thanks

3
9/3/2015 8:54:42 AM
15993 Reputation 2214 Total posts

Hi,

there is no walk through but you can find more info on forums and we have just open sourced a CalendarEvent search provider on GitHub so you can try to implement your own using that sample.

https://github.com/MonoSoftware/MonoX-CalendarEvent-SearchProvider

http://monox.mono-software.com/Mono/Pages/Discussion/dtopic/0NlQSWbliEq4HKBNAVYFYQ/Custom-MonoX-Search-Provider/

BTW can you please open a new topic rather then hijacking 2 years old topic :)

Regards

4
This is a demo site for MonoX. Please visit Mono Software for more info.