Bug 25051 - Elasticsearch truncates range searches when QueryAutoTruncate is enabled
Summary: Elasticsearch truncates range searches when QueryAutoTruncate is enabled
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact:
URL:
Keywords:
: 27955 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-04-03 13:32 UTC by Nick Clemens (kidclamp)
Modified: 2023-11-01 14:09 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens (kidclamp) 2020-04-03 13:32:28 UTC
To test:
1 - Enable QueryAutoTruncate
2 - Try a search like:
    copydate:[1990 TO 2010]
3 - Esplosions! Or at least, the search fails with error log like:
[Request] ** [http://es:9200]-[400] [query_shard_exception] Failed to parse query [(copydate:[1990* TO* 2010])], with: {"index_uuid":"lYb_5AVrT7iyEgLK-TGewg","index":"koha_kohadev_biblios"}, called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/Search.pm line 100. With vars: {'request' => {'path' => '/koha_kohadev_biblios/_search','mime_type' => 'application/json','serialize' => 'std','ignore' => [],'body' => {'query' => {'query_string' => {'fields' => ['cn-bib-source','number-legal-deposit','number-db','other-control-number','stock-number','ff7-00','cn-prefix','cn-class','local-classification','report-number','language-original','notforloan','number-natl-biblio','materials-specified','barcode','totalissues','arp','related-title','bio','index-term-genre','ff8-23','date-of-acquisition','number-govt-pub','title-series','identifier-publisher-for-music','pl','copydate','ctype','title-abbreviated','su-geo','host-item-number','author-in-order','ff7-02','title-uniform','identifier-other','cn-sort','ln-subtitle','author-name-corporate','personal-name','nlm-call-number','material-type','ccode','coden','name-geographic','itype','arl','restricted','copynumber','reading-grade-level','host-item','replacementprice','title-later','subject','isbn','title','title-other-variant','title-collective','stack','code-institution','name-and-title','ff8-29','corporate-name','cn-bib-sort','location','number-local-acquisition','homebranch','coded-location-qualifier','nal-call-number','ln-audio','author-name-personal','control-number','record-source','date-time-last-modified','extent','acqsource','bgf-number','related-periodical','interest-grade-level','interest-age-level','koha-auth-number','date-entered-on-file','holdingbranch','lc-card-number','curriculum','note','map-scale','author-personal-bibliography','abstract','bib-level','identifier-standard','ln','name','subject-name-personal','lost','withdrawn','itemtype','ta','editor','dewey-classification','uri','music-key','price','biblioitemnumber','itemnumber','provider','local-note','indexed-by','rtype','title-former','code-geographic','issues','classification-source','lc-call-number','replacementpricedate','record-control-number','cn-suffix','cross-reference','publisher','title-expanded','ff7-01','author','conference-name','contents','index-term-uncontrolled','datelastborrowed','thematic-number','local-number','datelastseen','reserves','not-onloan-count','title-key','title-cover','bnb-card-number','udc-classification','renewals','ff7-01-02','date-of-publication','lf','cn-item','dissertation-information','geographic-class','issn','damaged','author-title','lexile-number','llength','microform-generation'],'default_operator' => 'AND','query' => '(copydate:[1990* TO* 2010])','fuzziness' => 'auto','lenient' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),'analyze_wildcard' => $VAR1->{'request'}{'body'}{'query'}{'query_string'}{'lenient'}}},'size' => '20','from' => 0,'aggregations' => {'su-geo' => {'terms' => {'size' => '20','field' => 'su-geo__facet'}},'author' => {'terms' => {'field' => 'author__facet','size' => '20'}},'location' => {'terms' => {'field' => 'location__facet','size' => '20'}},'title-series' => {'terms' => {'size' => '20','field' => 'title-series__facet'}},'itype' => {'terms' => {'field' => 'itype__facet','size' => '20'}},'ccode' => {'terms' => {'field' => 'ccode__facet','size' => '20'}},'ln' => {'terms' => {'size' => '20','field' => 'ln__facet'}},'holdingbranch' => {'terms' => {'field' => 'holdingbranch__facet'}},'subject' => {'terms' => {'size' => '20','field' => 'subject__facet'}}}},'qs' => {},'method' => 'GET'},'body' => {'status' => 400,'error' => {'failed_shards' => [{'index' => 'koha_kohadev_biblios','reason' => {'index' => 'koha_kohadev_biblios','reason' => 'Failed to parse query [(copydate:[1990* TO* 2010])]','caused_by' => {'type' => 'parse_exception','reason' => 'Cannot parse \'(copydate:[1990* TO* 2010])\': Encountered " <RANGE_GOOP> "TO* "" at line 1, column 17.
Was expecting:
    "TO" ...
    ','caused_by' => {'reason' => 'Encountered " <RANGE_GOOP> "TO* "" at line 1, column 17.
Was expecting:
    "TO" ...
    ','type' => 'parse_exception'}},'type' => 'query_shard_exception','index_uuid' => 'lYb_5AVrT7iyEgLK-TGewg'},'shard' => 0,'node' => '-yc8mDy8SDu6U12yEpvXFA'}],'phase' => 'query','type' => 'search_phase_execution_exception','grouped' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ),'reason' => 'all shards failed','root_cause' => [{'index_uuid' => 'lYb_5AVrT7iyEgLK-TGewg','type' => 'query_shard_exception','reason' => 'Failed to parse query [(copydate:[1990* TO* 2010])]','index' => 'koha_kohadev_biblios'}]}},'status_code' => 400}
Use of uninitialized value $error in concatenation (.) or string at /kohadevbox/koha/catalogue/search.pl line 558.
Comment 1 Andrew Fuerste-Henry 2021-08-25 20:20:28 UTC
*** Bug 27955 has been marked as a duplicate of this bug. ***
Comment 2 Anneli Österman 2023-11-01 14:09:22 UTC
In my tests (version 22.11 and in PTFS Europe's sandbox v. 23.06) QueryAutoTruncate affects also when you try to make the search "available:true". 

If QueryAutoTruncate is set to "Automatically" the search works if you use the Availability facet but not when you write the same search term in the search box. If you set the system preference to "only if * is added" the search term "available:true" works also in search box.

Is this the same error or should I file a new bug for this one?