Copied to clipboard

Flag this post as spam?

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


  • Hugo Migneron 32 posts 105 karma points
    Nov 25, 2013 @ 23:59
    Hugo Migneron
    0

    Examine : Querying against multiple ISearchCriteria

    I am using the Fluent API to create a search filer. Something like 

    var fluentSearchFilter = searchCriteria.NodeTypeAlias("SomeAlias")
                    .And()
                    .Field("SomeFieldAlias", someValue);
    
    var results = umbracoHelper.TypedSearch(fluentSearchFilter.Compile()); //This works fine

    This works fine and I get the results I want / should get with the query.

    I also need to use raw lucene queries for something that's a bit more complex and that the fluent API doesn't cover. Once again, this is fine : 

    var rawSearchFilter = searchCriteria.RawQuery(myComplexRawQuery);
    var results = umbracoHelper.TypedSearch(rawSearchFilter);

    Now what I would like to do is combine the 2 ISearchCriteria objects. Basically, one query that will return the results that satisfy both fluentSearchFilter and rawSearchFilter­. Is there a way to create a ISearchCriteria from 2 ISearchCriteria objects like that?

    If there isn't, I am guessing that I will need to take the first ISearchCriteria (the one that I create with the fluent API), get the Lucene query from it and then create one big Lucene query by combining it to myComplexRawQuery. But once again, I am not sure how to even get the raw lucene query from an existing ISearchCriteria.

    I know this sounds like i'm not really trying... I can see it in Visual Studio  but I just can't figure out how to get the string!

    Does anyone know how to do this or how to achieve an equivalent result?

    Thanks a lot!!

Please Sign in or register to post replies

Write your reply to:

Draft