boolean operator

Help
2006-03-27
2013-05-28
  • Nobody/Anonymous

    I to all
    (I apologize for my english)

    In advanced (or simple) search, I need (for example) search 2 keywords in field keyword (or Author) togheter with AND or OR operator:

    Keywords:  contains |_____________________|
                         key01 AND key02

    or

    Keywords:  contains |_____________________|
                         key01 OR key02

    I try but without success.

    I see the example:
    Examples:   SELECT author, title, year, publication FROM refs WHERE publication = "Polar Biology" AND author RLIKE "Legendre|Ambrose" ORDER BY year DESC, author

    My attention it's on:
    "Legendre|Ambrose"  = Legendre AND Ambrose(?)
    The symbol " | "  it's (And Or Not)

    (I hope to able clear)

    TIA
    ipas

     
    • Nobody/Anonymous

      Now I found:

      | = OR  (AuthorA|AuthorB) =
      search AuthorA OR AuthorB

      But no found the operator for AND (and NOT)

      Help?

      TIA
      ipas

       
      • Matthias Steffens

        Hi,

        by default, refbase allows the use of MySQL regular expressions within the form fields of its search pages. You can read more about the used search syntax here:

        http://wiki.refbase.net/index.php/Searching#Search_syntax

        this wiki page lists also pointers to learn more about MySQL regular expressions and regular expressions in general.

        Here's how to perform and "AND" search:

        The easiest way to search for two keywords (key01 AND key02) is to perform two subsequent searches: Start you search searching for key01, then use the "Search within Results" form above the search results list to search for key02. This will return all records that match key01 and key02. You can click the "your query" link in the results header to view the actual SQL query that was executed by refbase. There you'll see that refbase issued a query like:

        ... WHERE keywords RLIKE "key01" AND keywords RLIKE "key02" ...

        Using 'sql_search.php', you can, of course, type a similar query manually.

        In order to search for two keywords within the same field, Regex geeks can also enter a query such as:

        (key01.+key02|key02.+key01)

        which will find all records where the searched field contains both keywords (key01 and key02) in any order, i.e. either key01 followed by key02 or the other way round. But I guess that for for most people, the above method of performing two subsequent searches is more intuitive and easier to remember.

        Here's how to perform and "OR" search:

        If you want to search, say, the keywords field for key01 OR key02, the easiest way of doing this is to use the alternation metacharacter (i.e. the pipe character: |). For example entering this:

        key01|key02

        into the keywords field of any search page will find all records whose keywords field either contains key01 or key02. You could also manually enter a SQL query such as this:

        ... WHERE keywords RLIKE "key01" OR keywords RLIKE "key02" ...

        into the query form provided by 'sql_search.php' to achieve the same effect.

        Hope this helps, Matthias

         
    • Matthias Steffens

      Here's how to perform an "AND NOT" search:

      If you want to find all records whose, say, keyword field contains key01 but which do NOT contain key02, the easiest method is again to perform two subsequent searches: As described in my last post, start your search by searching for key01. Then use again the "Search within Results" form above the search results list to search for key02 and mark the "Exclude matches" checkbox. This will find all records that contain key01 and do not contain key02.

      Clicking on the "your query" link, you'll see that refbase translates this into a SQL query that reads:

      ... WHERE (keywords NOT RLIKE "key02" ... ) AND keywords RLIKE "key01" ...

      which, again, could be entered manually as well.

      Best, Matthias

       
    • Nobody/Anonymous

      Thanks Matthias

      you write:
      In order to search for two keywords within the same field, Regex geeks can also enter a query such as:

      (key01.+key02|key02.+key01)

      which will find all records where the searched field contains both keywords (key01 and key02) in any order, i.e. either key01 followed by key02 or the other way round. But I guess that for for most people, the above method of performing two subsequent searches is more intuitive and easier to remember.
      ----
      Perfect for me
      <<to search for two keywords within the same field>> I can use:
      (key01.+key02|key02.+key01)

      (I now go study MySQL regular expressions)

      But the last question is:
      exist a mode/sintax for search 2 (or more) keywords in any order avoiding a double sintax?
      (key01.+key02|key02.+key01)

      and finally
      THANKS for this best software to all developer.

      ipas

       
      • Matthias Steffens

        > exist a mode/sintax for search 2 (or more) keywords in any order
        > avoiding a double sintax?
        > (key01.+key02|key02.+key01)

        No, unfortunately not - at least I'm not aware of a regex query that searches for multiple keywords without listing all possible arrangements in the query.

        If you want to search for more than two keywords connected by AND, it may be easier to either use subsequent searches (as described in my previous posts) or to manually type the SQL query, which shouldn't be too difficult:

        ... WHERE keywords RLIKE "key01" AND keywords RLIKE "key02" AND keywords RLIKE "key03" AND keywords RLIKE "key04" ...

        Matthias

         
    • Nobody/Anonymous

      Thanks for reply Matthias.

      Future implementation  :-)))

      Title    |_________________|
      Author   |_________________|
      Keyword1 |_________________|
      Keyword2 |_________________|
      Keyword3 |_________________|
      ...

      Again thank for your works
      ipas

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks