Copied to clipboard

Flag this post as spam?

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

  • Fengelz 106 posts 221 karma points
    Jul 01, 2013 @ 16:56

    Examine search multiple fields


    I've been trying my luck with examine in Umbraco 6.0.5 for a couple of days now, without 100% success. Which is to say, I managed to get some search results, but not always the correct ones. First I thaught it was my indexes that was set up incorrect, but it doesnt appear so. 

    My seach criteria looks something like this: 

     var query = searchCriteria
                            .Field("nodeName", "skandinavien").Or()
                            .Field("bodyText", "skandinavien")

    I know for a fact that at least one page in my system contains the word "skandinavien" in the field bodyText, but the seachquery above returns 0 results.

    If I however do this:

     var query = searchCriteria
                            .Field("bodyText", "skandinavien")

    I get 3 results.

    In other words it seems to ignore the bodytext parameter in the first query. 

    Can somebody tell me what I'm doing wrong?


    - Sune

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Jul 01, 2013 @ 17:18
    Ismail Mayat


    It looks like the first query is an And query so its looking for nodeName must contain skandinavien or bodyText. I usually just munge all fields into one field then query on that see

  • David Brendel 774 posts 2843 karma points c-trib
    Jul 01, 2013 @ 17:22
    David Brendel


    try using this:

    var searchCriteria = Searcher.CreateSearchCriteria(BooleanOperation.Or);
    var query = searchCriteria.Field("nodeName", searchTerm).Or().Field("bodyText", searchTerm).Compile();

    Thing this will make it work. Had the same problem when tried to use examine the first time.

  • Fengelz 106 posts 221 karma points
    Jul 02, 2013 @ 09:23

    @Ismail Great article. Hereby bookmarked :)

    @David Thanks. That totally did the trick :D


Please Sign in or register to post replies

Write your reply to: