elasticsearch-grails-plugin
elasticsearch-grails-plugin copied to clipboard
fields, in serch result, lastUpdated and dateCreated return null values
Hi. I'm using elasticsearch-grails-plugin (elasticsearch: 0.0.3.5) in my project. I created the index:
package elastic.search
class Action {
String name
Date createDate = new Date()
Date deleteDate
Date lastUpdated
Date dateCreated
String notes
Service service
User createUser
static constraints = {
deleteDate nullable: true
service nullable: true
createUser nullable: true
}
static searchable = true
}
I'm searching in index:
def search = {
def result = []
def res = elasticSearchService.search("")
res.searchResults.each {
if(it instanceof Action) {
result.add(it)
}
}
}
As a result in "result", fields lastUpdated and dateCreated return null values????
I am using DataSource
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:mysql://localhost/elasticsearch"
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "***_"
password = "**_**"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
}
}
You are using Autotimestamp
. Have you checked the actual values?
Seems to me that your fields aren't properly indexed when they are autofilled by grails. I'm not sure why though, I'll have to recreate the problem.
In the meantime, I generally try not to work with instances returned by the plugin directly, as all non mapped fields will be null
. What you could do is change your result.add(it)
to result.add(Action.get(it.id))
. That will get the objects from the database without missing fields.
I am used elasticsearch-head-master, and as a result fields lastUpdated and dateCreated return is not null values!
Maybe this is a bug of the plugin or I am not correct used. Plugin used GORM. Fields lastUpdated and dateCreated in GORM Autotimestamp
How do I get these values in the index?
Same problem with 0.0.4.2 - datecreated is not indexed - if a copy the field to a second field called created - the date is indexed very well so it seems to be a problem with the datecreated - autotimestamp mechanism of grails. even after a re-index the values are null - the datbase of course has the correct values.
i can reproduce this bug aswell. funnyli if you define a custom converter for dateCreated (we use joda time for Autotimestamps), the converter is called but the resulting object still hast null values in dateCreated.
I'm also experiencing this issue - both dateCreated and lastUpdated are always null. Did anybody find a solution to this problem?