Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Manish 373 posts 932 karma points
    Jun 26, 2017 @ 08:26
    Manish
    0

    Examine search : How to merge two results in a single result

    Hi All,

    I want to merge two result into a single result and want to Place result of first criterion at top and then add result of second criteria.

    Any code snippet to achieve this?

    Thanks

  • Craig Mayers 164 posts 508 karma points
    Jun 26, 2017 @ 09:23
    Craig Mayers
    0

    Hi Manish,

    Can you post the code you already have?

    Craig

  • Manish 373 posts 932 karma points
    Jun 26, 2017 @ 09:44
    Manish
    0
     var term_split = SearchTerm.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
     var Searcher = Examine.ExamineManager.Instance.SearchProviderCollection["MySearcher"];
                    var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.And);
                    var searchCriteriaPhrase = Searcher.CreateSearchCriteria(BooleanOperation.And);
    var fieldsToSearch = new[]
                    {
                 "type", "topic",  "format", "nodeName", "createDate", "updateDate", "bannerTitle", "pageContentSection",
                    "bannerText", "articleDescription", "shortDescription", "level1Tag", "level2Tag",  "articleBody", "newsBody", "articlePublishedDate"
                };
    
                     IBooleanOperation filterPhrase = searchCriteriaPhrase.GroupedOr(fieldsToSearch, Phrase);
                     IBooleanOperation filter = searchCriteria.GroupedOr(fieldsToSearch, term_split);
          IEnumerable<SearchResult> SearchResult = Searcher.Search(filter.Compile());
    
  • Manish 373 posts 932 karma points
    Jun 26, 2017 @ 09:49
    Manish
    0

    Basically I have two filter

    1. filterPhrase
    2. filter

    and I want result of filterPhrase first then want to add result of filter just after this and want to show in this order.

    Thanks

  • Manish 373 posts 932 karma points
    Jun 29, 2017 @ 05:36
    Manish
    101

    Able to get something like this.

    Searcher.Search(filterPhrase.Compile()).Concat(Searcher.Search(filter.Compile())).Distinct();
    

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft