Ticket #157 (closed defect: released)

Opened 20 months ago

Last modified 19 months ago

Boolean filters shouldn't always combine with AND

Reported by: richard Owned by: olly
Priority: normal Milestone:
Component: QueryParser Version: SVN trunk
Severity: normal Keywords:
Cc: andreas Blocked By:
Operating System: All Blocking:

Description

Currently, the query parser always combines boolean filter terms together with AND. In addition, it doesn't handle explicit boolean operators usefully (the result is sometimes useful, but not consistently).

The query parser should be modified to combine boolean filter terms with the same prefix together with OR, and then combine those groups with different prefixes together with AND. The query parser should also respect explicit operators, such that (where a and b are boolean prefixes for A and B).

"a:foo a:bar" becomes "Afoo OR Abar" "a:foo b:bar" becomes "Afoo AND Bbar" "a:foo AND a:bar" becomes "Afoo AND Abar" "a:foo OR b:bar" becomes "Afoo OR Abar"

A tricky case is:

"foo OR a:bar" - this could become "foo OR Abar", but the resulting weights may not be useful.

Attachments

patch1 (1.7 kB) - added by richard 20 months ago.
Patch adding relevant tests to queryparsertest
patch1.2 (6.9 kB) - added by richard 20 months ago.
Implementation of ORring filter terms with the same prefix
boolgroups.patch (11.4 kB) - added by richard 20 months ago.
Updated implementation of ORring filter terms with the same prefix
boolgroups.2.patch (10.9 kB) - added by richard 20 months ago.
Further updated patch
boolgroups.3.patch (10.0 kB) - added by richard 20 months ago.
Further update to patch
boolgroups.4.patch (11.6 kB) - added by richard 20 months ago.
Further update - adds documentation and a test case

Change History

Changed 20 months ago by richard

Changed 20 months ago by richard

  • attachments.isobsolete changed from 0 to 1

Changed 20 months ago by richard

Patch adding relevant tests to queryparsertest

Changed 20 months ago by richard

Note - Olly pointed out that the patch doesn't handle value range filters correctly (since these don't have a prefix - instead having a slot number).

There's also the issue about what to do about prefixes which have multiple names - eg, if add_prefix('author', 'A') and add_prefix('writer', 'A') have been called, what should "author:foo writer:bar" produce? I'm tending towards thinking that "Afoo AND Abar" is appropriate, mainly because it's easier to document, but I'm not fully convinced.

Changed 20 months ago by andreas

  • cc andreas@… added

Changed 20 months ago by richard

Changed 20 months ago by richard

  • attachments.isobsolete changed from 0 to 1

Changed 20 months ago by richard

Implementation of ORring filter terms with the same prefix

Changed 20 months ago by richard

Changed 20 months ago by richard

  • attachments.isobsolete changed from 0 to 1

Changed 20 months ago by richard

Updated implementation of ORring filter terms with the same prefix

Changed 20 months ago by richard

Changed 20 months ago by richard

  • attachments.isobsolete changed from 0 to 1

Changed 20 months ago by richard

Further updated patch

Changed 20 months ago by richard

Further update - adds documentation and a test case

Changed 20 months ago by richard

  • attachments.isobsolete changed from 0 to 1

Changed 20 months ago by olly

  • status changed from new to closed
  • resolution set to fixed

Patch applied, so fixed in SVN HEAD.

Changed 19 months ago by olly

  • resolution changed from fixed to released

Fixed in 1.0.1.

Changed 19 months ago by trac

  • platform set to All
Note: See TracTickets for help on using tickets.