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

    Me too. Any luck figuring this out?

  • Nik 1304 posts 5529 karma points MVP 3x 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 104 posts 347 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 489 posts 3205 karma points MVP 2x 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 104 posts 347 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!

  • aaeda 113 posts 145 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 333 posts 1298 karma points
    14 days ago
Please Sign in or register to post replies

Write your reply to:

Draft