[
https://issues.apache.org/jira/browse/METAMODEL-172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14708980#comment-14708980
]
ASF GitHub Bot commented on METAMODEL-172:
------------------------------------------
Github user kaspersorensen commented on a diff in the pull request:
https://github.com/apache/metamodel/pull/43#discussion_r37730850
--- Diff:
elasticsearch/src/main/java/org/apache/metamodel/elasticsearch/ElasticSearchUtils.java
---
@@ -44,8 +47,17 @@ public static Row createRow(Map<String, Object>
sourceMap, String documentId, Da
values[i] = documentId;
} else {
Object value = sourceMap.get(column.getName());
-
- values[i] = value;
+
+ if (column.getType() == ColumnType.DATE) {
+ Date valueToDate = TimeComparator.toDate(value);
--- End diff --
Maybe it's better that we put in the ES module the time format that ES
uses. I guess the TimeComparator is a bit more general purpose while I imagine
(?) that ES is always using one specific date pattern.
> ElasticSearch Date types should be converted properly
> -----------------------------------------------------
>
> Key: METAMODEL-172
> URL: https://issues.apache.org/jira/browse/METAMODEL-172
> Project: Apache MetaModel
> Issue Type: Bug
> Reporter: Alberto
> Priority: Critical
>
> When working with ElasticSearch indexes that contains Date types the API is
> returning Strings instead of proper Date object.
> We should add some logic inside the ElasticSearchUtils createRow() method to
> convert these strings to java.Date objects. As we are not doing this
> conversion so far the TimeComparator convertFromString method is not able to
> parse the string value as a Date, the method returns null and then the
> FormatHelper class is throwing an IllegalStateException.
> This is a bit tricky though because the number of date formats supported by
> ElasticSearch is quite big to think about creating a SimpleDateFormat to
> support every single case:
> https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)