Bugzilla – Attachment 175423 Details for
Bug 38694
Boost exact title matches in Elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38694: Title boost ES (WIP)
Bug-38694-Title-boost-ES-WIP.patch (text/plain), 2.47 KB, created by
Nick Clemens (kidclamp)
on 2024-12-12 21:47:40 UTC
(
hide
)
Description:
Bug 38694: Title boost ES (WIP)
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-12-12 21:47:40 UTC
Size:
2.47 KB
patch
obsolete
>From a6761b2314d7545c48a030438246bf8694395a2d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 12 Dec 2024 21:42:22 +0000 >Subject: [PATCH] Bug 38694: Title boost ES (WIP) > >This patch is a rough example, needs work and tests >--- > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index ad240bdde60..4f682c093b0 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -200,18 +200,25 @@ sub build_query { > if ($options{whole_record}) { > push @$fields, 'marc_data_array.*'; > } >- $res->{query} = { >- query_string => { >+ my $query_string = { > query => $query, > fuzziness => $fuzzy_enabled ? 'auto' : '0', > default_operator => 'AND', > fields => $fields, > lenient => JSON::true, > analyze_wildcard => JSON::true, >+ }; >+ $query_string->{type} = 'cross_fields' if C4::Context->preference('ElasticsearchCrossFields'); >+ >+ $res->{query} = { >+ bool => { >+ must => [ >+ {query_string => $query_string} >+ ] > } > }; >- $res->{query}->{query_string}->{type} = 'cross_fields' if C4::Context->preference('ElasticsearchCrossFields'); > >+ $res->{query}->{bool}->{should} = [ {match => { 'title-cover' => { query => $options{simple_query} } }}] if $options{simple_query}; > if ( $options{sort} ) { > foreach my $sort ( @{ $options{sort} } ) { > my ( $f, $d ) = @$sort{qw/ field direction /}; >@@ -262,6 +269,9 @@ sub build_query_compat { > $lang, $params ) > = @_; > >+ warn Data::Dumper::Dumper("rat", $operators," rand", $operands," ind", $indexes); >+ my $simple_query; >+ $simple_query = $operands->[0] if ( scalar @{$operands} == 1 && $operators && $indexes && !@{$operators} && !@{$indexes} ); > my $query; > my $query_str = ''; > my $search_param_query_str = ''; >@@ -314,6 +324,7 @@ sub build_query_compat { > $options{is_opac} = $params->{is_opac}; > $options{weighted_fields} = $params->{weighted_fields}; > $options{whole_record} = $params->{whole_record}; >+ $options{simple_query} = $simple_query; > $query = $self->build_query( $query_str, %options ); > } > >-- >2.39.5
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 38694
:
175423
|
175459
|
175840
|
175841
|
175842