From 61b5f2fbbe26d4f472f29315808606ee7d36b12a Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Tue, 28 May 2024 17:48:11 +0200
Subject: [PATCH] - removed 'source' search - added 'fuzzy' search

---
 .../TA/Archivematica/Elasticsearch/PrepareQuery.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/SLUB/LZA/TA/Archivematica/Elasticsearch/PrepareQuery.pm b/lib/SLUB/LZA/TA/Archivematica/Elasticsearch/PrepareQuery.pm
index 948ea1f..988ee73 100644
--- a/lib/SLUB/LZA/TA/Archivematica/Elasticsearch/PrepareQuery.pm
+++ b/lib/SLUB/LZA/TA/Archivematica/Elasticsearch/PrepareQuery.pm
@@ -13,9 +13,6 @@ sub prepare_aip_query ($opt) {
     if (exists $opt->{maxrecords}) {
         $query->{size} = $opt->{maxrecords};
     }
-    if (exists $opt->{source}) {
-        #push @queries, "IE.sourceMD.content=\"$opt->{source}\"";
-    }
     if (exists $opt->{aip}) {
         push @must, {
             "match_phrase" => {
@@ -96,7 +93,16 @@ sub prepare_aip_query ($opt) {
         push @should, {
             "multi_match" => {
                 "query" => "$opt->{descriptive}",
-                "fields" => ["transferMetadata.*"] # scan all metadata
+                "fields" => ["transferMetadata.*"] # scan all metadata, exact match
+            }
+        }
+    }
+    if (exists $opt->{fuzzy}) {
+        push @should, {
+            "multi_match" => {
+                "query" => "$opt->{fuzzy}",
+                "fields" => ["transferMetadata.*"], # scan all metadata, phrase match
+                "type" => "phrase_prefix",
             }
         }
     }
-- 
GitLab