MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Search functionality  (Mono Support )

Viewed 8533 time(s), 4 post(s) 11/15/2013 12:45:52 AMby mmorozov

Related topics

mmorozov

mmorozov

11/15/2013 12:45:52 AM
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. 
This content has not been rated yet. 
95 Reputation 10 Total posts
khorvat

khorvat

11/19/2013 11:19:15 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts
Kezber

Kezber

9/2/2015 8:11:33 PM

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

Thanks

This content has not been rated yet. 
215 Reputation 29 Total posts
khorvat

khorvat

9/3/2015 8:54:42 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts