Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 363 posts 917 karma points
    Jun 26, 2013 @ 14:01
    Craig O'Mahony
    0

    Searching on multiple search words in examine

    Hi I wonder if anyone could assist, I'm trying to set up examine to search my site.

    Firstly I know that this question has been asked before but unfortunately I still can't seem to get it to work (mainly because I don't know enough about examine/lucene) so if someone could spare a minute or 3 that would be great.

    This works fine if the search term is only one work but what I'm trying to get is a multi search term working so for instance if someone searches for Legal Training I would like examine to search for Legal and Training and not just the phrase legal training.

    Here's what I have so far.

            var searcher = ExamineManager.Instance.SearchProviderCollection["CLTSearcher"];
            var criteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
            SearchTerm = Request.QueryString["s"];
            if (string.IsNullOrEmpty(SearchTerm)) return;
            var filter = criteria
                .GroupedOr(new string[] { "nodeName", "bodyText" }, SearchTerm)
                .Not()
                .Field("umbracoNavihide", "1")
                .Compile();
            SearchResults = searcher.Search(filter);

            SearchResultListing.DataSource = SearchResults;
            SearchResultListing.DataBind();
            litCount.Text = "<h4>Your search for <strong><em>" + SearchTerm + "</em></strong> returned " + SearchResults.Count().ToString() + " results</h4>";

     

    Like I say this works fine for just a single word.

    Could anybody help please?

    Thanks,

    Craig

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies