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

    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 104 posts 347 karma points
    Sep 04, 2019 @ 21:40
    Blake Clerke

    Me too. Any luck figuring this out?

  • Nik 1365 posts 5953 karma points MVP 3x c-trib
    Sep 04, 2019 @ 22:49

    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?



  • Blake Clerke 104 posts 347 karma points
    Sep 05, 2019 @ 01:30
    Blake Clerke

    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 510 posts 3420 karma points MVP 2x c-trib
    Sep 05, 2019 @ 06:24
    Søren Kottal

    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 104 posts 347 karma points
    Sep 05, 2019 @ 19:03
    Blake Clerke

    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!

  • aaeda 113 posts 145 karma points
    Jan 09, 2020 @ 10:49


    I am having an issue with multiple search terms. Please see below the code I am using. It is not working. var searchResults = Searcher.CreateQuery("content").NodeTypeAlias("aNNONCES").And().Field("quartier", searchTerm2).Or().Field("quartier", "Telfair").Execute();

    Do you have any idea of how it can be done?

    Thanks A.

  • David Armitage 409 posts 1648 karma points
    Jul 23, 2020 @ 06:35
Please Sign in or register to post replies

Write your reply to: