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 304 posts 503 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 Watt (Clerke) 106 posts 351 karma points MVP
    Sep 04, 2019 @ 21:40
    Blake Watt (Clerke)
    0

    Me too. Any luck figuring this out?

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Sep 04, 2019 @ 22:49
    Nik
    102

    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 Watt (Clerke) 106 posts 351 karma points MVP
    Sep 05, 2019 @ 01:30
    Blake Watt (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 702 posts 4497 karma points MVP 5x 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 Watt (Clerke) 106 posts 351 karma points MVP
    Sep 05, 2019 @ 19:03
    Blake Watt (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!

  • aaeda 117 posts 150 karma points
    Jan 09, 2020 @ 10:49
    aaeda
    0

    Hello

    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 505 posts 2073 karma points
    Jul 23, 2020 @ 06:35
  • chinachin 2 posts 71 karma points
    Jul 25, 2020 @ 06:19
    chinachin
    0

    Thank you for updating this topic

Please Sign in or register to post replies

Write your reply to:

Draft