Copied to clipboard

Flag this post as spam?

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


  • Gordon Saxby 1444 posts 1855 karma points
    Jul 26, 2017 @ 10:05
    Gordon Saxby
    0

    Examine find results where 2 out of 3 fields match

    I want to search the Umbraco Members to find records that match on at least 2 out of 3 fields.

    For example, if I have FieldA, FieldB and FieldC - I want to create a search that supplies values for all 3 fields (but the value may be "") and I want to find records where at least 2 of those fields match the provided values.

    Is this something that Examine can do natively, or do I need to do an "Or" search and find the "2 out of 3" matches myself?

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Jul 26, 2017 @ 11:12
    Alex Skrypnyk
    0

    Hi Gordon

    It looks like you just need to change index configuration, just add your fields to Examine index, it should be enough for this functionality.

    Thanks,

    Alex

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 26, 2017 @ 11:59
    Gordon Saxby
    0

    Hi Alex,

    the 3 fields are part of the index, that's not the problem. I want to return results where at least two of the fields match, or all three ... but not where just one matches.

    So, where:

    FieldA and FieldB

    or FieldA and FieldC

    or FieldB and FieldC

    etc

    I was wondering if the examine score would help me but it's value looks too complicated to figure out!

    It would be good if I could have a "value" field that was "1" if only one field matched, "2" for two fields matching and "3" for three fields matching.

    I was hoping that there was some way to do this with the Examine search, rather than having to get all the results back and filtering them using C#.

  • Gordon Saxby 1444 posts 1855 karma points
    Jul 27, 2017 @ 11:18
    Gordon Saxby
    0

    OK, by testing with the query tool in Umbraco Developer section, I think I need a query like this:

    (+FieldA:valueA +FieldC:valueC) (+FieldA:valueA +FieldB:valueB) (+FieldB:valueA +FieldC:valueC)
    

    So - how do I create that with FluentAPI?!!

Please Sign in or register to post replies

Write your reply to:

Draft