Skip to content

Commit fb2dc0c

Browse files
max-zillalmarini
andauthored
Add numeric and date fields, gt lt gte lte operators (#76)
* Support colons in search box & metadata search * remove logging * Add support for other operators in search api & search box * Clean up != behavior, include gte lte in UI * Clean up regex and parsing for exists and missing queries * remove space sensitivity to searches * improve documentation * Fixed spacing check * handle colons on contains matches better * Add numeric detection to mapping * disable lt gt lte gte * update help syntax * Simplify help * colon warning * Add lt gt lte gte back to available operators * enable date_detection explicitly * Update CHANGELOG.md * omit redundant date_detection flag * update search help descriptions Co-authored-by: Luigi Marini <[email protected]>
1 parent e7ae152 commit fb2dc0c

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2020

2121
## 1.11.1 - 2020-09-29
2222

23+
**_Warning:_ This update modifies information stored in Elasticsearch used for text based searching. To take advantage
24+
of these changes a reindex of Elasticsearch is required. A reindex can be started by an admin from the Admin menu.**
25+
2326
### Added
24-
- Added healtz endpoint that is cheap and quick to return, useful for kubernetes live/ready checks.
27+
- added healtz endpoint that is cheap and quick to return, useful for kubernetes live/ready checks.
28+
- added support for parsing of Date and Numeric data in new metadata fields. New search operators <, >, <=, >= have been
29+
added to search API now that those data are properly compared.
2530

2631
### Fixed
2732
- Fixed health check script when using custom path prefix.

app/services/ElasticsearchPlugin.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
4949
val nameOfIndex = play.api.Play.configuration.getString("elasticsearchSettings.indexNamePrefix").getOrElse("clowder")
5050
val maxResults = play.api.Play.configuration.getInt("elasticsearchSettings.maxResults").getOrElse(240)
5151

52-
// TODO: Removed gt lt gte lte operators until numeric_detection can be enabled on the dynamic mapper
53-
val mustOperators = List("==", ":") // "<=", ">=", "<", ">", ":")
52+
val mustOperators = List("==", "<=", ">=", "<", ">", ":")
5453
val mustNotOperators = List("!=")
5554

5655

@@ -696,9 +695,8 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
696695
* as strings for datatypes besides Objects. In the future, this could
697696
* be removed, but only once the Search API better supports those data types (e.g. Date).
698697
*/
699-
// TODO: Enable "numeric_detection": true alongside date_detection
700698
"""{"clowder_object": {
701-
|"date_detection": false,
699+
|"numeric_detection": true,
702700
|"properties": {
703701
|"name": {"type": "string"},
704702
|"description": {"type": "string"},
@@ -847,8 +845,7 @@ class ElasticsearchPlugin(application: Application) extends Plugin {
847845

848846
// Use regex to split string into a list, preserving quoted phrases as single value
849847
val matches = ListBuffer[String]()
850-
val m = Pattern.compile("([^\":= ]+|\".+?\")").matcher(query)
851-
//val m = Pattern.compile("([^\":=<> ]+|\".+?\")").matcher(query)
848+
val m = Pattern.compile("([^\":=<> ]+|\".+?\")").matcher(query)
852849
while (m.find()) {
853850
var mat = m.group(1).replace("\"", "").replace("__", " ").trim
854851
if (mat.length>0) {

app/views/metadatald/search.scala.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ <h1>Search Metadata within Space: "@space.name"</h1>
205205
"<option value='=='>equals</option>" +
206206
"<option value='!='>does not equal</option>" +
207207
"<option value=':'>contains</option>" +
208-
//"<option value='>'>greater than</option>" +
209-
//"<option value='<'>less than</option>" +
210-
//"<option value='>='>greater or equal to</option>" +
211-
//"<option value='<='>less or equal to</option>" +
208+
"<option value='>'>greater than</option>" +
209+
"<option value='<'>less than</option>" +
210+
"<option value='>='>greater or equal to</option>" +
211+
"<option value='<='>less or equal to</option>" +
212212
"</select></div>" +
213213
<!-- VALUE FIELD -->
214214
"<div class='form-group col-lg-4 col-md-4'>" +

app/views/searchResults.scala.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ <h1>Search</h1>
3232
<div class="panel-body">
3333
<ul>
3434
<li>@Messages("help.search.overview1")</li>
35+
<li>@Messages("help.search.overview4")<br/><t/>@Messages("help.search.overview6")</li>
3536
<li>@Messages("help.search.overview2")</li>
3637
<li>@Messages("help.search.overview3")</li>
38+
<li>@Messages("help.search.overview5")</li>
3739
</ul>
3840
<table style="width:100%;">
3941
<tr><td width="120"><b>operator</b></td>
4042
<td width="400"></td></tr>
4143
<tr><td><b>==</b></td><td>equals</td></tr>
4244
<tr><td><b>!=</b></td><td>does not equal</td></tr>
4345
<tr><td><b>:</b></td><td>contains</td></tr>
44-
<!--
4546
<tr><td><b>< ></b></td><td>less than / greater than</td></tr>
4647
<tr><td><b><= >=</b></td><td>less or equal to / greater or equal to </td></tr>
47-
-->
4848
</table></br>
4949
<table style="width:100%;">
5050
<tr><td width="120"><b>@Messages("help.search.col1")</b></td>

conf/messages

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ securesocial.login.useEmailAndPassword=Or login using an email and password.
6262
securesocial.login.useEmailAndPasswordOnly=Login using an email and password.
6363

6464
#Search help text
65-
help.search.toggle=Search Syntax
65+
help.search.toggle=Search Syntax Help
66+
help.search.overview4=When searching for extractor-generated metadata, the entire extractor path with periods replaced as underscores must be included as a prefix.
67+
help.search.overview6=e.g.: "https://mysite_com/clowder/extractors/my_extractor.field"<20
6668
help.search.overview1=If the term or metadata field contains spaces or colons, use double quotes to enclose the phrase.
6769
help.search.overview2=You can use * as a wildcard character.
6870
help.search.overview3=Case does not matter unless noted.
69-
help.search.overview5=(Elasticsearch regular expression syntax help)
71+
help.search.overview5=When searching date fields, the date formats must match (YYYY-MM-DD will not match YYYY/MM/DD)
7072
help.search.col1=field
7173
help.search.col2=example
7274
help.search.allfields=name, description, creator name, and tag

0 commit comments

Comments
 (0)