Sales Questions
Topic: Re: How do I make sure that words with hyphens ("-") get included in my results?
Karamasoft Support Forums

Page 1 of 1 (11 items)

Posted by mikeArrowTruck on 02-23-2015 8:59 AM
Hello our users are experiencing a failure in getting any results when a site search is performed using words with hyphens ("-") in them. We have upgraded to the latest version but are still experiencing this problem. Is there a way to configure the config file to include words / file names with hyphens in them? Do you have an example of this or documentation that shows how to successfully configure the search to return files/results with hyphens in the file name?

Posted by Karamasoft on 02-23-2015 11:24 AM
Hyphen ("-") is a word-breaker, and there is no configuration to treat it differently. It will always break the word and index them separately. If you want to find those words together in your search, you convert your search terms into exact search such as "my-word" by wrapping the word inside double-quotes. Please see the Customize Search Operation sample at

Posted by mikeArrowTruck on 02-26-2015 2:17 PM
Ok. So is this a property of the UltimateSearchInput control, or is this something that I have to do in the C# behind, in the OnClick event of the Search button?

Posted by mikeArrowTruck on 02-26-2015 2:25 PM
I think I understand better after looking through some of the documentation. I would need to add this:

     <SearchTypeList RepeatLayout="Flow" RepeatDirection="Horizontal" Visible="True">
               <asp:ListItem Value="0" Selected="True">All Words</asp:ListItem>
               <asp:ListItem Value="1">Any Word</asp:ListItem>
               <asp:ListItem Value="2">Exact Phrase</asp:ListItem>
               <asp:ListItem Value="3">Partial Match</asp:ListItem>

To my cc1:UltimateSearchInput control, and then have the user select option 2: "Exact Phrase". Is that correct? Can I only offer the option 2 in addition to the All Words option? Like:

     <SearchTypeList RepeatLayout="Flow" RepeatDirection="Horizontal" Visible="True">
               <asp:ListItem Value="0" Selected="True">All Words</asp:ListItem>
               <asp:ListItem Value="1">Exact Phrase</asp:ListItem>

Posted by Karamasoft on 02-26-2015 4:30 PM
You don't have to change your UI to show these search type selections, which require user intervention. Instead, you should handle this in your C# code (aspx.cs page) behind the scenes. If you take a look at the Customize Search Operation sample at, which we suggested earlier, you'll see that you can change the search terms string in the UltimateSearchInput1_Click event handler. For instance, you can check whether it contains any "-" characters, and if so you can either wrap them inside double quotes such as "my-word" or set the search type before redirecting to the search output page. Then it will handle them as exact match.

Posted by mikeArrowTruck on 02-27-2015 8:32 AM
Ok. Thank you. I thought about that being what you may have meant, but remembered, last Oct., experimenting with some of the other features of the control and thought that maybe you meant that by using that feature, I could achieve what I'm after. Ok, well I'm all about the code behind so I think this will help me out. Thank you. If I have further questions, I'll post them. Thanks again.

Posted by mikeArrowTruck on 02-27-2015 9:00 AM
So something like this:

        protected void UltimateSearchInput1_Click(object sender, System.EventArgs e)
            // Get search terms
            //string searchTerms = UltimateSearchInput1.SearchTextBox.Text.Trim();

            string searchTerms = "";
            string strSearchText = UltimateSearchInput1.SearchTextBox.Text.Trim();

            if (strSearchText.Contains("-"))
                searchTerms = "\"" + UltimateSearchInput1.SearchTextBox.Text.Trim() + "\"";
                searchTerms = UltimateSearchInput1.SearchTextBox.Text.Trim();

            // Check search terms
            if (ValidSearchTerms(searchTerms))
                // Get search output page
                string outUrl = UltimateSearchInput1.SearchOutputPage;
                // Check search output page
                if (outUrl == null)
                    outUrl = Page.Request.Path;
                    outUrl = Page.ResolveUrl(outUrl);
                // Build query string
                string queryStr = outUrl + "?usterms=" + searchTerms;
                // If you display the RadioButtonList control to get the search type
                if (UltimateSearchInput1.SearchTypeList.Visible)
                    queryStr += "&ustype=" + UltimateSearchInput1.SearchTypeList.SelectedValue;
                // Redirect to search output page
                Page.Response.Redirect(queryStr, true);

Posted by Karamasoft on 02-27-2015 9:38 AM
If you wrap the search terms inside double-quotes, setting the ustype could be redundant or irrelevant as you may notice in your tests. In other words, double-quotes should be sufficient as it's treated as exact match by definition. Did you achieve your requirements with this code?

Posted by mikeArrowTruck on 02-27-2015 11:02 AM
I believe so: I got this in message on my page when I entered:


into the seach (text) box: (I can't attach an image in here so i'll just type it below)

Your search - "w-9" - did not match any documents.

Posted by mikeArrowTruck on 02-27-2015 11:39 AM
Above you wrote: "...setting the ustype..."? What is the "ustype" and where did I set it?

Posted by Karamasoft on 02-27-2015 12:57 PM
if (UltimateSearchInput1.SearchTypeList.Visible)
queryStr += "&ustype=" + UltimateSearchInput1.SearchTypeList.SelectedValue;