From 11e00954d376e8a8438bcae7acf082202562514b Mon Sep 17 00:00:00 2001 From: Akash A Date: Thu, 5 Jul 2018 15:32:37 +0100 Subject: [PATCH] add filename search as a chip this will make it easier to debug errors from s3 watcher --- .../gu/mediaservice/lib/elasticsearch/ImageFields.scala | 9 +++++++-- .../js/search/structured-query/query-suggestions.js | 3 ++- media-api/app/lib/querysyntax/QuerySyntax.scala | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ImageFields.scala b/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ImageFields.scala index 88cc3eb238..381a0312f5 100644 --- a/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ImageFields.scala +++ b/common-lib/src/main/scala/com/gu/mediaservice/lib/elasticsearch/ImageFields.scala @@ -43,14 +43,19 @@ trait ImageFields { def collectionsField(field: String) = s"collections.$field" def usagesField(field: String) = s"usages.$field" + val aliases = Map( + "crops" -> "exports", + "croppedBy" -> "exports.author", + "filename" -> "uploadInfo.filename" + ) + def getFieldPath(field: String) = field match { case f if metadataFields.contains(f) => metadataField(f) case f if usageRightsFields.contains(f) => usageRightsField(f) case f if editsFields.contains(f) => editsField(f) case f if collectionsFields.contains(f) => collectionsField(f) case f if usagesFields.contains(f) => usagesField(f) - case "crops" => "exports" - case f => f + case f => aliases.getOrElse(f, f) } } diff --git a/kahuna/public/js/search/structured-query/query-suggestions.js b/kahuna/public/js/search/structured-query/query-suggestions.js index a07afffe89..ab3eb5a618 100644 --- a/kahuna/public/js/search/structured-query/query-suggestions.js +++ b/kahuna/public/js/search/structured-query/query-suggestions.js @@ -30,7 +30,8 @@ export const filterFields = [ 'usages@platform', 'usages@status', 'has', - 'croppedBy' + 'croppedBy', + 'filename' ].sort(); // TODO: add date fields diff --git a/media-api/app/lib/querysyntax/QuerySyntax.scala b/media-api/app/lib/querysyntax/QuerySyntax.scala index 234a5c300d..d04a36f4d7 100644 --- a/media-api/app/lib/querysyntax/QuerySyntax.scala +++ b/media-api/app/lib/querysyntax/QuerySyntax.scala @@ -106,7 +106,8 @@ class QuerySyntax(val input: ParserInput) extends Parser with ImageFields { "collection" | "keyword" | "label" | - "croppedBy" + "croppedBy" | + "filename" } def resolveNamedField(name: String): Field = (name match { @@ -118,7 +119,6 @@ class QuerySyntax(val input: ParserInput) extends Parser with ImageFields { case "location" => "subLocation" case "by" | "photographer" => "byline" case "keyword" => "keywords" - case "croppedBy" => "exports.author" case fieldName => fieldName }) match { case "publication" => MultipleField(List("publicationName", "publicationCode"))