Bugzilla – Attachment 135334 Details for
Bug 30152
Elasticsearch - queries with OR don't work with limits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30152: Elasticsearch - queries with OR don't work with limits
Bug-30152-Elasticsearch---queries-with-OR-dont-wor.patch (text/plain), 2.72 KB, created by
Kevin Carnes
on 2022-05-25 08:46:21 UTC
(
hide
)
Description:
Bug 30152: Elasticsearch - queries with OR don't work with limits
Filename:
MIME Type:
Creator:
Kevin Carnes
Created:
2022-05-25 08:46:21 UTC
Size:
2.72 KB
patch
obsolete
>From ce69530a23610d6efc46437331c574409bc5b59c Mon Sep 17 00:00:00 2001 >From: Kevin Carnes <kevin.carnes@ub.lu.se> >Date: Tue, 22 Feb 2022 14:29:15 +0100 >Subject: [PATCH] Bug 30152: Elasticsearch - queries with OR don't work with > limits > >When a query with "OR" is combined with a limit in Elasticsearch, the precedence is not preserved and the results are not correct. > >To test: >1) Set SearchEngine to Elasticsearch >2) Index records in Elasticsearch >3) Do an advanced search >4) Select More options >5) Enter a value for the first Keyword (e.g. Novels) >6) Change "and" before the second Keyword to "or" >7) Enter another value for the second Keyword (e.g. Prose) >8) Limit the search (e.g. Item type Books) >9) Do the search >10) Observe that records with the first keyword are not in the results >11) Apply the patch >12) Repeat the search >13) Observe that results with both keywords are in the results >14) Sign off > >Sponsored-by: Lund University Library >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + > t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t | 9 ++++++++- > 2 files changed, 9 insertions(+), 1 deletion(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index dba475eb3c..5934956326 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -306,6 +306,7 @@ sub build_query_compat { > # them into a structured ES query itself. Maybe later, though that'd be > # more robust. > $search_param_query_str = join( ' ', $self->_create_query_string(@search_params) ); >+ $search_param_query_str = "($search_param_query_str)"; > $query_str = join( ' AND ', > $search_param_query_str || (), > $self->_join_queries( $self->_convert_index_strings(@$limits) ) || () ); >diff --git a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >index e7d3b2ae62..62c822831b 100755 >--- a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >+++ b/t/db_dependent/Koha/SearchEngine/Elasticsearch/Search.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use t::lib::Mocks; > > use Koha::SearchEngine::Elasticsearch::QueryBuilder; >@@ -84,6 +84,13 @@ is( $searcher->index, 'mydb', 'Testing basic accessor' ); > > ok( my $query = $builder->build_query('easy'), 'Build a search query'); > >+my (undef, $or_query) = $builder->build_query_compat( ['OR'], ['a', 'b'], undef, ['mc-itype:c'] ); >+is( >+ $or_query->{query}->{query_string}->{query}, >+ '((a*) OR (b*)) AND itype:("c")', >+ 'Testing OR query with limit' >+); >+ > SKIP: { > > eval { $builder->get_elasticsearch_params; }; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30152
:
131010
|
131011
|
131017
|
131018
|
135334
|
135360
|
135446
|
135454
|
135793
|
136569
|
136766