Re: [Koha-devel] Elasticsearch query with suppress:false not returning expected results
Hi Philippe, Your second query appears to be correct. Is it possible that one of the "expropriation" records is suppressed in the the OPAC? Try searching for "title:expropriation AND suppress:true" (without QueryAutoTruncate). It's possible to automatically add parentheses to both the query and the limits by editing the Koha/SearchEngine/Elasticsearch/QueryBuilder.pm file. After "$search_param_query_str = join( ' ', $self->_create_query_string(@search_params) );" add: if ($search_param_query_str) { $search_param_query_str = "($search_param_query_str)"; } my $search_param_limits_str = $self->_join_queries( $self->_convert_index_strings(@$limits) ); if ($search_param_limits_str) { $search_param_limits_str = "($search_param_limits_str)"; } And then change the "$query_str" to: $query_str = join( ' AND ', $search_param_query_str || (), $search_param_limits_str || () ); Hopefully that will produce the correct results. Regards, Kevin
Hi Kevin, You were right, one of the indexed record was "hidden" so the second result was correct (24 Acceptabilité + 1 Expropriation). I skipped it thinking the 25 was actually just 25 "acceptabilité" returned. Now, writting the query differently does it. * (title:acceptabilité) OR (title:expropriation) ANDsuppress:false 1 résultat * ((title:acceptabilité) OR (title:expropriation)) ANDsuppress:false 25 résultats But it's not what Koha is doing. Can I interpret that this is a bug I should open and provide a fix for ? Thanks a lot, Philippe On 2022-02-18 09:33, Kevin Carnes wrote:
Hi Philippe,
Your second query appears to be correct. Is it possible that one of the "expropriation" records is suppressed in the the OPAC? Try searching for "title:expropriation AND suppress:true" (without QueryAutoTruncate).
It's possible to automatically add parentheses to both the query and the limits by editing the Koha/SearchEngine/Elasticsearch/QueryBuilder.pm file. After "$search_param_query_str = join( ' ', $self->_create_query_string(@search_params) );" add: if ($search_param_query_str) { $search_param_query_str = "($search_param_query_str)"; } my $search_param_limits_str = $self->_join_queries( $self->_convert_index_strings(@$limits) ); if ($search_param_limits_str) { $search_param_limits_str = "($search_param_limits_str)"; }
And then change the "$query_str" to: $query_str = join( ' AND ', $search_param_query_str || (), $search_param_limits_str || () );
Hopefully that will produce the correct results.
Regards, Kevin
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website :https://www.koha-community.org/ git :https://git.koha-community.org/ bugs :https://bugs.koha-community.org/
participants (2)
-
Kevin Carnes -
Philippe Blouin