We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13808
    • 61 Posts
    I'm using AdvSearch in Revolution and would like to run a search that carries a bit of relevance by running an AND query followed by an OR query, then combining the two results with the AND results running above the OR results. This way it would find exact matches ahead of possible matches.

    I've been looking at the queryHook but what I'm trying to do seems like it may be above the scope of the examples I could find.

    Anyone have thoughts on the best way to do this?
      • 5811
      • 1,717 Posts

      With AdvSearch you can run a query like (word1 AND word2) OR word3
      As example on this demo page : http://www.revo.wangba.fr/query-syntax.html run a search with the following queries:

      (villarica AND chile) OR (masaya AND nicaragua)
      (villarica OR chile) AND (masaya OR nicaragua)


      Could you give us an example of the query you would like
        • 13808
        • 61 Posts
        Thanks for your response coroico and thanks for writing this amazing search function. It's so comprehensive. This is the first time I've used it and I'm really impressed by it.

        To pull an example from the demo pages: if I search "rock band" (but without the quotes) my ideal result set would be to return a single list of results in the following order with the duplicates removed:
        - "rock band" (using the quotes)
        - rock AND band
        - rock OR band

        This effectively is doing the work of 3 searches for the user and making some approximate decisions about what's most likely to be relevant.

        What I'm currently trying is writing a snippet that actually runs 3 searches by calling the AdvSearch snippet 3 times with the different parameters. Using a TPL that just returns '[[+id]],' I can then explode that into an array of the three sets, remove the duplicates and cycle through those IDs with getResource to list the results.

        It's a bit more manual but in my mind it will create a more precise search.

        Am I missing something that automates some or all of this?

        Thanks again!