Home Search Member List Faq Register Login  
Sales Questions
Re: How do I make sure that words with hyphens ("-") get included in my results?

Thread Starter: mikeArrowTruck   Started: 02-23-2015 8:59 AM   Replies: 10
 Karamasoft Support Forums » General Discussions » Sales Questions » Re: How do I make sure that words with hyphens ("-") get included in my results?
 Printable Version    « Previous Thread
  23 Feb 2015, 8:59 AM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
How do I make sure that words with hyphens ("-") get included in my results?
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?

  
  23 Feb 2015, 11:24 AM
Karamasoft is not online. Last active: 11/10/2017 3:24:14 PM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,818
Re: How do I make sure that words with hyphens ("-") get included in my results?
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 https://karamasoft.com/Samples.aspx?component=UltimateSearch&sample=CustomSearch.
  
  26 Feb 2015, 2:17 PM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
Re: How do I make sure that words with hyphens ("-") get included in my results?
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?

  
  26 Feb 2015, 2:25 PM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
Re: How do I make sure that words with hyphens ("-") get included in my results?
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">
          <Items>
               <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>
          </Items>
     </SearchTypeList>

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">
          <Items>
               <asp:ListItem Value="0" Selected="True">All Words</asp:ListItem>
               <asp:ListItem Value="1">Exact Phrase</asp:ListItem>
          </Items>
     </SearchTypeList>

  
  26 Feb 2015, 4:30 PM
Karamasoft is not online. Last active: 11/10/2017 3:24:14 PM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,818
Re: How do I make sure that words with hyphens ("-") get included in my results?
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 https://karamasoft.com/Samples.aspx?component=UltimateSearch&sample=CustomSearch, 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.
  
  27 Feb 2015, 8:32 AM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
Re: How do I make sure that words with hyphens ("-") get included in my results?
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.

  
  27 Feb 2015, 9:00 AM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
Re: How do I make sure that words with hyphens ("-") get included in my results?
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() + "\"";
            else
                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;
                else
                    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);
            }
        }

  
  27 Feb 2015, 9:38 AM
Karamasoft is not online. Last active: 11/10/2017 3:24:14 PM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,818
Re: How do I make sure that words with hyphens ("-") get included in my results?
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?
  
  27 Feb 2015, 11:02 AM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
Re: How do I make sure that words with hyphens ("-") get included in my results?
I believe so: I got this in message on my page when I entered:

        w-9

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.



  
  27 Feb 2015, 11:39 AM
mikeArrowTruck is not online. Last active: 7/11/2017 10:50:32 AM mikeArrowTruck

Top 10 Posts
Joined on 10-16-2014
Posts 13
Re: How do I make sure that words with hyphens ("-") get included in my results?
Above you wrote: "...setting the ustype..."? What is the "ustype" and where did I set it?

  
  27 Feb 2015, 12:57 PM
Karamasoft is not online. Last active: 11/10/2017 3:24:14 PM Karamasoft

Top 10 Posts
Joined on 09-05-2004
Posts 6,818
Re: How do I make sure that words with hyphens ("-") get included in my results?
if (UltimateSearchInput1.SearchTypeList.Visible)
queryStr += "&ustype=" + UltimateSearchInput1.SearchTypeList.SelectedValue;

  
 Page 1 of 1 (11 items)
Karamasoft Support Forums » General Discussions » Sales Questions » Re: How do I make sure that words with hyphens ("-") get included in my results?

You can add attachments
You can post new topics
You can reply to topics
You can delete your posts
You can edit your posts
You can create polls
You can vote in polls
Forum statistics are enabled
Forum is unmoderated

© 2002-2018 Karamasoft LLC. All rights reserved.