Try Now
More in this section

Forums / Deployment / Problems in ElasticSearch if your field contains an underscore

Problems in ElasticSearch if your field contains an underscore

1 posts, 0 answered
  1. eb-1988
    eb-1988 avatar
    23 posts
    24 Feb 2009
    14 Sep
    Link to this post

    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: http://xxxxxxxxxxxx:9200/underlinetest/_search?pretty=true

    I hope anybody can help us to solve this problem.


1 posts, 0 answered