Copied to clipboard

Flag this post as spam?

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


  • Shada 55 posts 137 karma points
    Aug 12, 2016 @ 21:31
    Shada
    0

    search content

    Hi! I need to add the ability to search for content by the "Title" field among the 3 types (category, property, organization).

    My controller:

    public class SearchController : SurfaceController
    {
        private readonly UmbracoHelper _uh = new UmbracoHelper(UmbracoContext.Current);
    
        [HttpPost]
        public ActionResult Find(string text)
        {
            var query = ExamineManager.Instance.CreateSearchCriteria()
                   .NodeName("category").Or()
                   .NodeName("property").Or()
                   .NodeName("organization")
                   .And().Field("title", text)
                   .Compile();
    
            var result = _uh.Search(query);
            return PartialView("~/Views/Partials/FindResult.cshtml", result);
        }
    }
    

    The structure of my site:

    -Categories

    -----Category (has Title)

    -Properties

    -----Property (has Title)

    -Organizations

    -----Organization (has Title)

    But it seems it does not work properly. Please any help

  • 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