]> git.koha-community.org Git - koha.git/commit
Bug 24902: Join different mc- limits with AND (elasticsearch)
authorJulian Maurice <julian.maurice@biblibre.com>
Thu, 19 Mar 2020 08:38:52 +0000 (09:38 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 24 Mar 2020 08:00:26 +0000 (08:00 +0000)
commit3302ad146194738c247b2ccfa7b8e3cb98478f7d
tree010390e5b7f1995bfa92a85e3f5e09ff56a12bb4
parentacf7ec2d872b3ac55259cf114b32bfc4c9163037
Bug 24902: Join different mc- limits with AND (elasticsearch)

In the advanced search form, you can enable several limits using syspref
AdvancedSearchTypes (namely itemtypes, shelving locations, collections)
When used, the resulting query parts end up being joined with OR, even
if the field is different. That means that if you pick "Book" under
itemtypes tab, and "Fiction" under collection tab, it will search
"itype:BOOK OR ccode:FIC". It should be AND.

For instance, if you select:
    Itemtypes:
        ✓ Book
        ✓ DVD
    Location:
        ✓ Child
        ✓ Adult

it should search:
    itype:(Book OR DVD) AND location:(Child OR Adult)

Test plan:
0. Do not apply the patch yet
1. Enable elasticsearch
2. Set syspref AdvancedSearchTypes = 'itemtypes|loc|ccode'
3. Create a new itemtype and a new authorised value for categories LOC
   and CCODE
4. Create a biblio with the new itemtype, another biblio with the new
   location, another biblio with the new collection, and again another
   biblio with the new itemtype, location and collection
5. Verify that you can find these new biblio records using only the
   "advanced search types" in the advanced search form
6. In the advanced search form, pick all 3 limits (itemtype, location,
   collection) and verify that it returns the 4 records.
7. Apply the patch
8. Repeat step 6, it should now return only the biblio that satisfies
   all criteria
9. Verify that if you select more than one
   {itemtype|location|collection} it still returns results that
   satisfies any selected criteria
10. prove t/Koha/SearchEngine/ElasticSearch/QueryBuilder.t

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/SearchEngine/Elasticsearch/QueryBuilder.pm
t/Koha/SearchEngine/ElasticSearch/QueryBuilder.t