1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Searching Wiki

Searching Wiki

13 posts, 0 answered
  1. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    30 Nov 2009
    Link to this post
    Hi,

    I'm looking to search the wiki manually by searching for specific wiki syntax ("[[some text]]") and am having trouble creating match regular expression pattern. If I were to type in "[quick lookup]" in my search to find [[quick lookup]] but NOT quick lookup what would be my regular expression pattern?

    Sorry, I'm really not that good at regular expressions.

    Thanks

    -Matt
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    01 Dec 2009
    Link to this post
    Hi Matt,

    You could try using similar expression as /[\[\]]/. The backslash escapes the square bracket so you could try to get the text inside or just check for the brackets.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    01 Dec 2009
    Link to this post
    Hi Ivan,

    Everything I seem to do brings back results both of the wiki as well as any search it finds with the words as well. For example if I search for "[Changing your password]" it brings back all pages with "Changing your password" in it regardless of whether or not it has square brackets around it.

    I'm basically looking to create a "backlinks" of sort for the wiki. I'm looking to display all pages that reference this specific wiki page. My thought was to search for the square bracket links using the search, but am having difficulty.

    As always your help is greatly appreciated.

    -Matt
  4. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    07 Dec 2009
    Link to this post
    I almost got it working. I set the matchPattern to
    <add matchPattern="\[.*?\]" replacementString='\[$1\]' enabled="true" matchAlert="hi"/> 

    I know this matches searches for [Some link] because if I remove the replacement string the alert of Hi shows up.

    I've tried a variety of replacementStrings but it seems to never find any of the wiki links as exact text.

    Any help would be appreciated.

    Thanks

    -Matt



  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 Dec 2009
    Link to this post
    Hello Matt,

    As far as I see it you are escaping the first bracket only. The Wiki link is formed like [[LINK]].

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    09 Dec 2009
    Link to this post
    <add matchPattern="\[\[(.*)\]\]" replacementString='\[\[$1\]\]' enabled="true" matchAlert="hi"/> 

    If I now search for [[some link]] it will find all wiki items with the words "some link" in it - i.e. not doing an exact match with the square brackets.

    Is it possible to do an exact match? It seems to me that the ReplacementString seems always to be stripping out to the square brackets even though I've explicitly have set them?

    Thoughts?


  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    10 Dec 2009
    Link to this post
    Hello Matt,

    I am not sure what regex validator you are using, and if it clears the brackets by purpose. The regex looks correct. You can try to use this tool - http://www.quanetic.com/Regex - to check the rule/matches on the fly. I hope that this will save you some time.  


    Kind regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    10 Dec 2009
    Link to this post
    So it looks like Sitefinity automatically strips out any special characters when you use the replacementString property, so you can't find specific text with square brackets. No matter how I set the replacement string it does not find that specific text WITH the square brackets. Yes it will find the exact text inside the square brackets, however I'm just specifically looking for wiki links so the results that are brought back aren't correct.

    Can you confirm that it does this? Is there any way around it?
  9. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    10 Dec 2009
    Link to this post
    Hello Matt,

    Please open the WikiCombinedSearchResult.ascx, the control you are probably using for showing the results (but the search is also performed there), and add the following property to the SearchResults control:

    <sfCtrl:SearchResult ID="commonSearchResult" runat="server" EscapeSpecialChars="false">

    In this case the special characters will not be stripped.

    Greetings,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    10 Dec 2009
    Link to this post
    Hi

    My ControlsConfig.xml is set to

     <viewSettings hostType="Telerik.Wiki.WebControls.Search.WikiCombinedSearchResult" layoutTemplatePath="~/MNP/Views/Wiki/WikiCombinedSearchResult.ascx" /> 

    My WikiCombinedSearchResults.acscx is the following:
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="sfWeb" %> 
    <%@ Register Assembly="Telerik.Wiki" Namespace="Telerik.Wiki.WebControls.Search" TagPrefix="sfCtrl" %> 
    <%@ Register Assembly="Telerik.Search" Namespace="Telerik.Search.WebControls" TagPrefix="sfCtrl" %> 
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %> 
     
     
    <asp:MultiView ID="resultTypes" runat="server"
     
        <asp:View ID="contentViewResultView" runat="server"
         
            <h2><asp:Literal ID="ContentViewResultStats" runat="server"></asp:Literal></h2
            <sfWeb:ContentView ID="contentViewResult" runat="server"
                <ItemListTemplate> 
                    <asp:Repeater ID="repeater" runat="server"
                         <HeaderTemplate> 
                                <dl class="searchResults"
                            </HeaderTemplate> 
                            <ItemTemplate> 
                                 <div class="searchResultItem">    
                                    <div class="searchResultTitle"
                                        <asp:HyperLink ID="fullContent1" runat="server"
                                            <asp:Literal ID="Name" runat="server"></asp:Literal> 
                                        </asp:HyperLink> 
                                     </div> 
                                     <div class="searchResultText"
                                     
                                     </div> 
                                </div> 
                            </ItemTemplate> 
                            <FooterTemplate> 
                                </dl> 
                            </FooterTemplate> 
                        </asp:Repeater> 
                        <sfWeb:Pager ID="pager1" runat="server"
                            <LayoutTemplate> 
                                 <asp:Repeater ID="PageRepeaterLinkButton" runat="server"
                                    <HeaderTemplate> 
                                        <ol class="sf_pager"
                                        <li><asp:LinkButton ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:LinkButton></li
                                    </HeaderTemplate> 
                                    <ItemTemplate> 
                                        <li> 
                                            <asp:LinkButton ID="SingleItem" runat="server" /> 
                                        </li> 
                                    </ItemTemplate> 
                                    <FooterTemplate> 
                                        <li><asp:LinkButton ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:LinkButton></li
                                        </ol> 
                                    </FooterTemplate> 
                                </asp:Repeater> 
                                <asp:Repeater ID="PageRepeaterHyperLink" runat="server"
                                    <HeaderTemplate> 
                                        <ol class="sf_pager"
                                        <li><asp:HyperLink ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:HyperLink></li
                                    </HeaderTemplate> 
                                    <ItemTemplate> 
                                        <li> 
                                            <asp:HyperLink ID="SingleItem" runat="server" /> 
                                        </li> 
                                    </ItemTemplate> 
                                    <FooterTemplate> 
                                        <li><asp:HyperLink ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:HyperLink></li
                                        </ol> 
                                    </FooterTemplate> 
                                </asp:Repeater> 
                            </LayoutTemplate> 
                        </sfWeb:Pager> 
                </ItemListTemplate> 
            </sfWeb:ContentView> 
        </asp:View> 
        <asp:View ID="commonSearchResultView" runat="server"
         
        <sfCtrl:SearchResult ID="commonSearchResult" runat="server" EscapeSpecialChars="false" > 
                <LayoutTemplate> 
                    <h2><asp:Literal ID="ResultsStats" runat="server" Text="<%$Resources:ResultsStats %>"></asp:Literal></h2
     
                    <asp:Repeater ID="rptResults" runat="server"
                        <HeaderTemplate> 
                            <ul class="sf_searchResults"
                        </HeaderTemplate> 
                        
                        <ItemTemplate>                      
                            <li> 
                                <strong><a href='<%#Eval("Url")%>'><%#Eval("Title")%></a></strong> 
                                <%#Eval("Snippet")%> 
                            </li> 
                        </ItemTemplate> 
                        <FooterTemplate> 
                            </ul> 
                        </FooterTemplate> 
                    </asp:Repeater> 
     
                    <sfWeb:Pager ID="pager1" runat="server"
                        <LayoutTemplate> 
                             <asp:Repeater ID="PageRepeaterLinkButton" runat="server"
                                <HeaderTemplate> 
                                    <ol class="sf_pager"
                                    <li><asp:LinkButton ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:LinkButton></li
                                </HeaderTemplate> 
                                <ItemTemplate> 
                                    <li> 
                                        <asp:LinkButton ID="SingleItem" runat="server" /> 
                                    </li> 
                                </ItemTemplate> 
                                <FooterTemplate> 
                                    <li><asp:LinkButton ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:LinkButton></li
                                    </ol> 
                                </FooterTemplate> 
                            </asp:Repeater> 
                            <asp:Repeater ID="PageRepeaterHyperLink" runat="server"
                                <HeaderTemplate> 
                                    <ol class="sf_pager"
                                    <li><asp:HyperLink ID="PreviousPage" runat="server" Text="<%$Resources:PreviousPage %>"></asp:HyperLink></li
                                </HeaderTemplate> 
                                <ItemTemplate> 
                                    <li> 
                                        <asp:HyperLink ID="SingleItem" runat="server" /> 
                                    </li> 
                                </ItemTemplate> 
                                <FooterTemplate> 
                                    <li><asp:HyperLink ID="NextPage" runat="server" Text="<%$Resources:NextPage %>"></asp:HyperLink></li
                                    </ol> 
                                </FooterTemplate> 
                            </asp:Repeater> 
                        </LayoutTemplate> 
                    </sfWeb:Pager> 
                </LayoutTemplate> 
            </sfCtrl:SearchResult> 
     
        </asp:View> 
        <asp:View ID="wikiSearchResultView" runat="server"
            <sfCtrl:WikiSearchResult ID="wikiSearchResult" runat="server" > 
            </sfCtrl:WikiSearchResult> 
        </asp:View> 
    </asp:MultiView> 

    Inside my web.config is
    <add matchPattern="\A[\*\?\~][^\s]*" replacementString="" enabled="false" matchAlert="You can not start your query using wildcards, modify your query and try again.."/> 
    <add matchPattern="[\!\^\(\)\{\}]" replacementString="" enabled="false" matchAlert="d"/> 
    <add matchPattern="\[\[(.*)\]\]" replacementString='"[[$1]]"' enabled="true" matchAlert="hi"/> 

    If I remove the double quotes on the replacementString so it shows '[[$1]]' the search comes back with the warning

    Strange characters should be enclosed between double quotation, modify your query and try again..


    If I leave on the double quotes, it simply searches for the exact phrase inside the square brackets.

    What am I missing?
  11. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Dec 2009
    Link to this post
    Hello Matt,

    Now we are to the point that we submit the special characters, in our case "[" and "]" to the search engine without stripping or escaping them, but looking it the source, it turns out that these characters cannot be used with the Lucene Search Engine. 

    The message you see is a result from catching an exception in the Lucene Engine itself, and returning the message rather than .net error. I had to take a look in the source earlier - apologies for that. 

    Unfortunately you will have to think for some other way for achieving your goal here. You can take a look at the Luncese Index Toolbox - http://www.getopt.org/luke/ - in order to work directly with the index files and run queries against them. This should help you out with understanding the valid queries and how Lucene works. 

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. MNP
    MNP avatar
    79 posts
    Registered:
    23 Apr 2008
    14 Dec 2009
    Link to this post
    Hi Georgi

    Thanks for the response. I knew something had to be stripping them as it just didn't work. I'll take a look into the link.

    For 4.0 are you still going to use Lucene Search Engine or are you switching to another method?

    Thanks

    -Matt
  13. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    15 Dec 2009
    Link to this post
    Hello Matt,

    We are still going to use Lucene, but will provide a new API and new Search Manager classes to work with it. It will be much more customizable, so we believe that you will like it.

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
13 posts, 0 answered