Copied to clipboard

Flag this post as spam?

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


  • Craig Cronin 303 posts 502 karma points
    May 14, 2019 @ 19:56
    Craig Cronin
    0

    Examine search query for multiple document types

    I'm trying to write a search query for examine in version 8 that picks up on multiple document types but can't quite see how it works.

    var results = searcher.CreateQuery("content") .NodeTypeAlias("goodReadPage").Or() .NodeTypeAlias("caseStudyPage").And()......

    Any help would be appreciated.

  • Blake Clerke 103 posts 346 karma points
    Sep 04, 2019 @ 21:40
    Blake Clerke
    0

    Me too. Any luck figuring this out?

  • Nik 1144 posts 4732 karma points MVP 2x c-trib
    Sep 04, 2019 @ 22:49
    Nik
    1

    Hi Blake,

    You should be able to do something like this:

    var query = searcher.CreateQuery("content").ManagedQuery(searchTerm) .And().GroupedOr(new [] {"__NodeTypeAlias"}, new [] {"nodeAlias1", "nodeAlias2", "nodeAlias3"});

    The ManagedQuery option will search all fields in the index.

    Does this help?

    Thanks

    Nik

  • Blake Clerke 103 posts 346 karma points
    Sep 05, 2019 @ 01:30
    Blake Clerke
    1

    Thanks for the help Nik, It appears that when I do that, it is returning an IBooleanOperation for the results (query in your example) and I'm not sure how to work with that.

    This is what I have: var results = searcher.CreateQuery("content").ManagedQuery(searchQuery).And().GroupedOr(new[] { "__NodeTypeAlias" }, new[] { "pcGridLayout", "accordion", "accordionItem", "pcSubscriptions" });

  • Søren Kottal 441 posts 2735 karma points MVP c-trib
    Sep 05, 2019 @ 06:24
    Søren Kottal
    1

    Hi Blake, you need to finish your query with .Execute(), like var results = searcher.CreateQuery("content").ManagedQuery(searchQuery).And().GroupedOr(new[] { "__NodeTypeAlias" }, new[] { "pcGridLayout", "accordion", "accordionItem", "pcSubscriptions" }).Execute();

  • Blake Clerke 103 posts 346 karma points
    Sep 05, 2019 @ 19:03
    Blake Clerke
    1

    Well I'm so glad that was an easy fix. I have been staring at this too long! That worked, thank you so much! :) You and Nik are great! On to the next steps!

Please Sign in or register to post replies

Write your reply to:

Draft