Skip to content

Commit 18a50a6

Browse files
author
Max Burnette
committed
support email field search
1 parent 7788e4c commit 18a50a6

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

app/services/ElasticsearchPlugin.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
299299
.startObject("default")
300300
.field("type", "standard")
301301
.endObject()
302+
.startObject("email_analyzer")
303+
.field("type", "custom")
304+
.field("tokenizer", "uax_url_email")
305+
.endObject()
302306
.endObject()
303307
.endObject()
304308
.startObject("index")
@@ -710,7 +714,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
710714
|"parent_of": {"type": "string", "include_in_all": false},
711715
|"creator": {"type": "string", "include_in_all": false},
712716
|"creator_name": {"type": "string"},
713-
|"creator_email": {"type": "string"},
717+
|"creator_email": {"type": "string", "search_analyzer": "email_analyzer", "analyzer": "email_analyzer"},
714718
|"created_as": {"type": "string"},
715719
|"created": {"type": "date", "format": "dateOptionalTime", "include_in_all": false},
716720
|"metadata": {"type": "object"},
@@ -844,7 +848,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
844848
}
845849

846850
// If a term is specified that isn't in this list, it's assumed to be a metadata field
847-
val official_terms = List("name", "creator", "resource_type", "in", "contains", "tag")
851+
val official_terms = List("name", "creator", "email", "resource_type", "in", "contains", "tag")
848852

849853
// Create list of "key:value" terms for parsing by builder
850854
val terms = ListBuffer[String]()
@@ -859,6 +863,10 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
859863
currterm += "child_of:"
860864
else if (mt == "contains")
861865
currterm += "parent_of:"
866+
else if (mt == "creator")
867+
currterm += "creator_name:"
868+
else if (mt == "email")
869+
currterm += "creator_email:"
862870
else if (!official_terms.contains(mt))
863871
currterm += "metadata."+mt+":"
864872
else

app/views/searchResults.scala.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ <h1>Search</h1>
5050
<td>name:VIS_SV_180_z1_1207272.png</td>
5151
<td>@Messages("help.search.name", Messages("dataset.title").toLowerCase, Messages("collection.title").toLowerCase)</td></tr>
5252
<tr><td>creator</td>
53-
<td>creator:5a8c4bd574d559ca9b46ef58</td>
53+
<td>creator:Smith</td>
5454
<td>@Messages("help.search.creator")</td></tr>
55+
<tr><td>creator</td>
56+
<td>email:janesmith@@email.com</td>
57+
<td>@Messages("help.search.email")</td></tr>
5558
<tr><td>resource_type</td>
5659
<td>resource_type:collection</td>
5760
<td>@Messages("help.search.resource_type", Messages("dataset.title").toLowerCase, Messages("collection.title").toLowerCase)</td></tr>

conf/messages

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ help.search.col2=example
7070
help.search.allfields=name, description, creator name, and tag
7171
help.search.regex1=get anything with "trees" or "streetcars" in basic fields
7272
help.search.name=searches file, {0} or {1} names
73-
help.search.creator=creator ID can be found in their profile URL
73+
help.search.creator=creator name
74+
help.search.email=creator email address
7475
help.search.resource_type=can be file, {0} or {1}
7576
help.search.tag=filter search results by specific tags
7677
help.search.in=a {0} or {1} ID can be specified

0 commit comments

Comments
 (0)