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
    Fengelz
    0

    Examine search multiple fields

    Hi. 

    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")
                            .Compile();

    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")
                            .Compile();

    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?

    Cheers

    - Sune

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

    Fengelz,

    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 http://thecogworks.co.uk/blog/posts/2012/november/examiness-hints-and-tips-from-the-trenches-part-2/

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jul 01, 2013 @ 17:22
    David Brendel
    1

    Hi,

    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
    Fengelz
    0

    @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:

Draft