Problems in ElasticSearch if your field contains an underscore - On Premise – Configurations & Setup - On Premise – Configurations & Setup - Progress Community
 On Premise – Configurations & Setup

Problems in ElasticSearch if your field contains an underscore

  • Problems in ElasticSearch if your field contains an underscore
  • Dear Sir or Madam,

    We have a problem with the sitefinity search.
    We use the Sitefinity Search implementaion for search in search index as described in your documentation.
    We have an array of strings which defines all custom fields that we want to search in.
    All custom fields will be work if we search for there values.
    Only the custom fields with contains underscore (for example Product_Name) don't work.
    We are using the elastic search service for indexing. In an item that was found by a field without underscore (for example Title), the underscore fields are filled with there values, but not found if we search explicit for there values.

    For testing and reproduction purposes i've set up a clean new Project (9.0.6000.0 PE).
    In this project i've set the following:
    Administration > Settings > Search: Choose Elasticsearch and set the "http://xxxxxxxx:9200/" url for Elasticsearch URL
    Administration > Module builder > Create a module with two extra custom fields "TitelWithoutUnderLine" and "titel_With_UnderLine"
    Add two or more items to this created module
    Administration > Search & indexes > Create a search index > give them a name > Add the custom fields to the "Additional fields for indexing" field > TitelWithoutUnderLine,Titel_With_UnderLine > Save changes
    Reindex this index
    create a webform in visual-studio and name ist "SearchTest.aspx"
    In the code-behind add the following code:
    string sSearchQuery = Request.QueryString["q"].ToString();
                SearchResultsBuilder Searcher = new SearchResultsBuilder();
                string[] sSearchFields = new string[] "title", "titelWithoutUnderLine", "titel_With_UnderLine" ;
                int iHitCount = 0;
                IEnumerable<IDocument> ResultList = new List<IDocument>();
                ResultList = Searcher.Search(sSearchQuery, "underlinetest", sSearchFields, sSearchFields, 0, 9999, out iHitCount);
    Now you can track the search results
    The problem is, that the sitefinity algorithm only matches the fields with the query if the field have no underscore.
    elasticsearch can search with underscore. You can test this against the elasticservice: xxxxxxxxxxxx:9200/.../_search

    I hope anybody can help us to solve this problem.