Copied to clipboard

Flag this post as spam?

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


  • Raluca Dumitru 33 posts 174 karma points
    Jun 17, 2019 @ 15:32
    Raluca Dumitru
    0

    Examine multiple fields search

    Hi everyone.

    Does anybody knows how to search multiple fields with Examine? This is my code for one field , but it would be great if I could search the title as well.

    var results = searcher.CreateQuery("content").NodeTypeAlias("topic").And().Field("topicBody", searchTerm).Execute();
    

    Thank you

  • Mila Pandurska 75 posts 354 karma points
    Jun 25, 2019 @ 07:11
    Mila Pandurska
    104

    Hi, Raluca, you can search in multiple field using the following query:

    var textFields = new[] { "title", "description",  "content", .... };
    var results = searcher.CreateQuery("content").NodeTypeAlias("topic").And().GroupedOr(textFields, searchTerm).Execute();
    

    I hope that this helps Mila

  • Raluca Dumitru 33 posts 174 karma points
    Jun 25, 2019 @ 11:24
    Raluca Dumitru
    0

    Brilliant. Thank you :)

  • Gurumurthy 56 posts 129 karma points
    May 22, 2024 @ 07:18
    Gurumurthy
    0

    Hello All,

    I have a requirement, to search using Examine, when I need to search for a single document type (home) and the results should match with exactly with 2 different fields. Below is my code, but this gives results as OR operation, but I need AND.

    The result should be for home document type where it should have match both fileds (contractIden-us and mFRIden-us).

    searchResults = index
                    .Searcher
                    .CreateQuery("content")
                    .NodeTypeAlias("home")
                    .And()
                    .Field("contractId_en-us", contractNumber)
                    .And()
                    .Field("mFRId_en-us", mfrNumber)
                    .Execute();
    

    Appreciate the help here, what's wrong with above query.

    Regards,

    Gurumurthy JV

  • 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