Copied to clipboard

Flag this post as spam?

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


  • Jason Espin 368 posts 1335 karma points
    Jun 11, 2015 @ 13:34
    Jason Espin
    0

    Searching for more than one value for a single field using Examine

    Hi all,

    I'm currently working with Examine and just need a quick bit of guidance with the shorthand methods provided to ensure I am getting the correct items returned from my query.

    Here is my code:

    ISearchCriteria tourContainerCriteria = externalSearcher.CreateSearchCriteria(BooleanOperation.Or);
                        IBooleanOperation tourQuery = tourContainerCriteria.Field("nodeTypeAlias", "tour").Or().Field("nodeTypeAlias", "tourRepository");
                        tourQuery = tourQuery.And().Field("siteNode", culture.Value.Id.ToString());
                        ISearchResults tours = externalSearcher.Search(tourQuery.Compile());
    

    This produces the following Lucence query when compiled:

    {nodeTypeAlias: tour nodeTypeAlias:tourrespository +siteNode: 1054}
    

    This essential returns all nodes that have a siteNode of 1054 that could have either of the nodeTypeAlias defined but also could not. So, really what this is returning at the moment I believe is nodes that have a siteNode of 1054 but ignoring the other criteria.

    What I need is nodes to be returned that have either:

    nodeTypeAlias: tourrepository and a siteNode: 1054
    
    and
    
    nodeTypeAlias: tour and a siteNode: 1054
    

    Any help with this issue would be greatly appreciated as I really don't want to write a full lucence query by hand for such a simple issue.

    Cheers,

    Jason

  • 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