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 364 posts 918 karma points
    Feb 09, 2016 @ 11:50
    Craig O'Mahony
    0

    Search using Examine on Multiple node properties for multiple search terms

    Hi all,

    After some advice really:

    I have a certain area of content in my site (jobs) which contain multiple node properties (jobTitle, location, salary, etc) and I want to build a page that the user can search this content block. So I'm going to use a series of fields on the search page to allow the user to enter search terms in or select from dropdowns, etc.

    So if they enter a value into the title then the jobTitle property should be searched. If they enter a job title and select a location then jobTitle should be search (for the job title!) and also location should be searched, etc etc etc and then return the list of matching results.

    Is examine capable of doing this because I can't find any examples of it or should I write a custom piece of code?

    Thanks, Sx

  • Kasper Holm 47 posts 180 karma points
    Feb 18, 2016 @ 08:41
    Kasper Holm
    0

    Hello Craig

    The short Answer is yes Examine is capable

    First you will have to set up the indexes

    https://our.umbraco.org/documentation/Reference/Config/ExamineSettings/

    Then when doing the search you will have to specify the fields you want to search in and the keywords to match the fields

     var searcher = ExamineManager.Instance.SearchProviderCollection["YourSearcherName"];
    
     var searchCriteria = searcher.CreateSearchCriteria(BooleanOperation.Or)
                    .Field("nodeName", nodename).
                    Or().Field("title", title).
                    Or().Field("description", description).
                    Or().Field("keywords", keywords).
                    Or().Field("header", header).
                    Or().Field("featuredHeader", featuredHeader).
                    Or().Field("bodyText", bodyText).Compile()
    

    Hope this helps, else let me know ill try and be more specific. :)

Please Sign in or register to post replies

Write your reply to:

Draft