6.7 beta 1: Bug in logic operators

Mark Barnes
Mark Barnes Member Posts: 15,432 ✭✭✭

Either I'm very sleepy, or there's a bug in the way that Logos is interpreting logic operators and parentheses when searching in 6.7. Maybe it's always been like this. But it's very confusing when search logic works in some cases and not others.

Take a search for God love. That's identical to God AND love, to (God AND love) and to (God love). So far so good. In other words, if there's no operator, the AND operator is assumed.

By the same logic, (God love) OR (Jesus peace) should give exactly the same search results as (God AND love) OR (Jesus AND peace). It doesn't. You can see that the search fails to parse, and Logos is searching for "or" as if it was a word, not an operator

Equally, ((God AND love), (Jesus AND peace)) ought to give the same results, too. It doesn't. (I appreciate I should expect some difference in counting, but the results should be the same.)

On the other hand ((God love), (Jesus peace)) does return exactly the same results as ((God AND love), (Jesus AND peace)), as you would expect. But actually both search results are wrong (all four terms are being ANDed).

It appears that there are two bugs here:

  1. The OR is not being recognised in (God love) OR (Jesus peace).
  2. The comma is not recognised in ((God love), (Jesus peace)), or in ((God AND love), (Jesus AND peace)).

This is my personal Faithlife account. On 1 March 2022, I started working for Faithlife, and have a new 'official' user account. Posts on this account shouldn't be taken as official Faithlife views!

Comments

  • Graham Criddle
    Graham Criddle MVP Posts: 33,250

    Maybe it's always been like this.

    I've just checked and I see the same behaviour on a 6.5 SR1 system I haven't updated yet.

  • Bradley Grainger (Logos)
    Bradley Grainger (Logos) Administrator, Logos Employee Posts: 12,121

    It's always been this way.

    A malformed Boolean expression is interpreted as a "bag of words" (instead of giving an "INVALID QUERY TRY AGAIN!" error; see also Google). You can't infer that because the search engine interprets "(God love)" (standalone) as "God AND love" that it always has that meaning when used in any context in any other query.

    We have plans to improve the feedback when you enter an "almost correct" Boolean query, perhaps with a "Did you mean...?" prompt. 

  • Mark Barnes
    Mark Barnes Member Posts: 15,432 ✭✭✭

    A malformed Boolean expression is interpreted as a "bag of words" (instead of giving an "INVALID QUERY TRY AGAIN!" error; see also Google). You can't infer that because the search engine interprets "(God love)" (standalone) as "God AND love" that it always has that meaning when used in any context in any other query.

    That doesn't explain ((God AND love), (Jesus AND peace)) returns different results to ((God AND love) OR (Jesus AND peace)).

    It's the former query that's interpreted incorrectly — the comma is being ignored (i.e. treated as an AND instead of an OR).

    Does that mean you can't use parentheses within a list?

    This is my personal Faithlife account. On 1 March 2022, I started working for Faithlife, and have a new 'official' user account. Posts on this account shouldn't be taken as official Faithlife views!

  • Bradley Grainger (Logos)
    Bradley Grainger (Logos) Administrator, Logos Employee Posts: 12,121

    That doesn't explain ((God AND love), (Jesus AND peace)) returns different results to ((God AND love) OR (Jesus AND peace)).

    Yes, it does. The former query is not syntactically valid.

    Does that mean you can't use parentheses within a list?

    The limitation is that Boolean operators cannot be used within a list. The comma operator and OR are not interchangeable.

  • Mark Barnes
    Mark Barnes Member Posts: 15,432 ✭✭✭

    The limitation is that Boolean operators cannot be used within a list.

    Thanks for the clarification.

    Anything you can do to alert users that their query may not have been interpreted correctly would be appreciated.

    This is my personal Faithlife account. On 1 March 2022, I started working for Faithlife, and have a new 'official' user account. Posts on this account shouldn't be taken as official Faithlife views!

  • MJ. Smith
    MJ. Smith MVP Posts: 54,952

    Is this wiki accurate? (I just added the last sentence.

    5. Lists

    Lists are used to specify alternative search items in a compact form. For example (who, whoever, whom) is a list that will match who or whoever or whom.
    Parentheses ( ) are optional in simple searches.

    Note you must use a list with proximity operators e.g. (who, whoever, whom) NEAR Christ because (who OR whoever OR whom) NEAR Christ will give incorrect results.
    Note you cannot use a list with logical operators as it will give incorrect results.

    But this wiki is inaccurate?

    Lists are a very useful feature which provide shortcuts in a number of searches. A list is written like this: (term1, term2, term3, etc.). When Logos encounters a list, it performs the search using just term1. Then it repeats the search using just term2, then with just term3, etc. Once it has finished, it then ORs the results. Here are some examples:

    • (Jesus, Christ) is equivalent to Jesus OR Christ
    • (Jesus, Christ) AND love is equivalent to (Jesus AND love) OR (Christ AND love)
    • (“My God”, “My Lord”) is equivalent to “My God” OR “My Lord”, showing that phrases can be used in a list.

    Lists are most useful when used with fields (see below), or when trying to ensure proximity operators are only used in the outer terms of your search. For example:

    • The search described earlier (master NEAR love) OR (master NEAR serve) OR (neighbor NEAR love) OR (neighbor NEAR serve) can be simplified to (master, neighbor) NEAR (love, serve). Logos treats the two lists separately, iterating through them until every combination as been reached, like this:
      • master NEAR love
      • master NEAR serve
      • neighbor NEAR love
      • neighbor NEAR serve

    Please note: Some people get confused as they equate the list with the OR command. They are not the same, even though in a very basic search they will perform in the same way. Remember, Logos iterates through lists, then ORs the results.

    Orthodox Bishop Alfeyev: "To be a theologian means to have experience of a personal encounter with God through prayer and worship."; Orthodox proverb: "We know where the Church is, we do not know where it is not."

  • Mark Barnes
    Mark Barnes Member Posts: 15,432 ✭✭✭

    MJ. Smith said:

    Is this wiki accurate?

    It was correct in what it says (though inevitably incomplete).

    Strictly speaking your addition should read "Note you cannot use boolean operators within a list as it will give incorrect results."

    (That is, you can use logical operators with a list, but not in a list.)

    This is my personal Faithlife account. On 1 March 2022, I started working for Faithlife, and have a new 'official' user account. Posts on this account shouldn't be taken as official Faithlife views!

  • MJ. Smith
    MJ. Smith MVP Posts: 54,952

    Orthodox Bishop Alfeyev: "To be a theologian means to have experience of a personal encounter with God through prayer and worship."; Orthodox proverb: "We know where the Church is, we do not know where it is not."

  • Dave Hooton
    Dave Hooton MVP Posts: 36,152

    Dave
    ===

    Windows 11 & Android 13

  • MJ. Smith
    MJ. Smith MVP Posts: 54,952

    Orthodox Bishop Alfeyev: "To be a theologian means to have experience of a personal encounter with God through prayer and worship."; Orthodox proverb: "We know where the Church is, we do not know where it is not."