Acq: Refactor General Search for more smarts and speed
This started in response to problems discussed around
https://bugs.launchpad.net/evergreen/+bug/967824 , but it really
addresses a distinct issue from that bug.
Acq General Search relies on lots of joins to make several tables in Acq
searchable by attributes of any of the other tables for rows that happen
to be related. This is about 1) making better joins and 2) making fewer
joins when you don't need them all for a given search.
Much thanks to Mike Rylander for help figuring out how to efficiently
implement the joins needed for acq.invoice, which is the tricky part.
Less importantly, but still significant for some searches, we also need
case insensitivity for searching on user-linked fields (General Search
always lets you search by any of username/family name/given name/barcode
for these fields) in order to take advantage of some indexes for speed.
This diagram of key Acq relationships is helpful:
https://docs.google.com/drawings/d/15ExkiYvq0skfobbocvPWxwdZkb7aykEZpLGfbP9PL04/view
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>