Copied to clipboard

Flag this post as spam?

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


  • Tom 120 posts 448 karma points
    Jul 04, 2017 @ 09:39
    Tom
    0

    Querying Examine - contains one of the strings in an array

    Hi

    Sorry, I'm having a little trouble explaning this in english...

    I have an Examine index on my news items. These news items have a property which is an json string of categories (ect. "1232,1423,2141").

    I have another string array that I need to match up against the items in the index.

    How do I make a search criteria for that?

    Thanks, Tom

  • Marcio Goularte 388 posts 1360 karma points
    Nov 09, 2017 @ 13:53
    Marcio Goularte
    0

    I'm with the same doubt.

  • Ismael 71 posts 354 karma points
    Nov 10, 2017 @ 01:32
    Ismael
    1

    Possibly something like

            var searchQry = criteria.NodeTypeAlias("NewsArticle");
    
            if (!string.IsNullOrWhiteSpace(filter.Category))
            {
                searchQry = criteria.GroupedOr(new string[] { "articleType" }, filter.Category.Split(','));
            }
    

    Where filter.Category is a comma separated string of items.

    On thing you might need to be wary of is that your category list in the your index may need to be space separated, ie "1232,1423,2141" => "1232, 1423, 2141"

    Cheers.

  • Alex Brown 129 posts 620 karma points
    Nov 10, 2017 @ 09:59
    Alex Brown
    0

    On Ismael's point, yeah the values need to be space separated on most circumstances. I've found it way easier searching on an index whereby data would be stored like "1232 1423 2141" rather than "1232,1423,2141" as wildcards tend to work better.

Please Sign in or register to post replies

Write your reply to:

Draft