Copied to clipboard

Flag this post as spam?

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


  • Chris 11 posts 30 karma points
    Nov 30, 2011 @ 12:09
    Chris
    0

    Filter on custom properties

    Hi I want to search only content which has a custom property (i.e. summary). Can I do this is the query? Could someone help with the syntax as I'm new to this. Cheers, Chris.

               var criteria = ExamineManager.Instance
                    .SearchProviderCollection["InternalSearcher"]
                    .CreateSearchCriteria();

                var filter = criteria
                    .GroupedOr(new string[] { "nodeName", "bodyText","summary"},
                               searchTerm)
                    .Compile();

                SearchResults = ExamineManager.Instance.SearchProviderCollection["InternalSearcher"]
                    .Search(filter);

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 30, 2011 @ 13:03
    Dirk De Grave
    0

    If you setup your filter to only search the summary property content, it will only return content which has this property, so, your above statement seems rather valid, although now you're also allowing to search in two additional fields.

    var filter = criteria.GroupedOr(new string[] { "summary" }, searchTerm).Compile();

    (Make sure your indexer is also indexing that field, otherwise no results will be returned of course)

     

    Cheers,

     

    /Dirk

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies