elasticsearch-grails-plugin icon indicating copy to clipboard operation
elasticsearch-grails-plugin copied to clipboard

fields, in serch result, lastUpdated and dateCreated return null values

Open aldsok opened this issue 10 years ago • 8 comments

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????

aldsok avatar Nov 03 '14 11:11 aldsok

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"
        }
    }

aldsok avatar Nov 03 '14 12:11 aldsok

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.

sircelsius avatar Nov 03 '14 12:11 sircelsius

I am used elasticsearch-head-master, and as a result fields lastUpdated and dateCreated return is not null values!

aldsok avatar Nov 03 '14 12:11 aldsok

Maybe this is a bug of the plugin or I am not correct used. Plugin used GORM. Fields lastUpdated and dateCreated in GORM Autotimestamp

aldsok avatar Nov 03 '14 12:11 aldsok

How do I get these values ​​in the index?

aldsok avatar Nov 03 '14 12:11 aldsok

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.

langerc avatar Feb 12 '15 11:02 langerc

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.

peh avatar Feb 19 '15 15:02 peh

I'm also experiencing this issue - both dateCreated and lastUpdated are always null. Did anybody find a solution to this problem?

TomTirapani avatar Mar 16 '15 16:03 TomTirapani