3

I have domain classes which looks like following

class Post {

    String title
    String body


    //common
    Date dateCreated
    Date lastUpdated

    //Mappings
    static belongsTo = [user:User]
    static hasMany = [comments:Comment,tags:TagBlog]

    static mapping = {
        body type:"text"
    }

    static constraints = {
        title nullable:false,blank:false
        body nullable: false, blank:false
    }
     static searchable = {
        except = 'user'

    }

}

and

class Comment {

    String comment
    int vote

    //common
    Date dateCreated
    Date lastUpdated

    static belongsTo = [post:Post,user:User]

    static mapping = { comment type:"text" }
    static constraints = {
        comment nullable:false,blank:false
        vote nullable:true,blank:true
    }
    static searchable = {
        except = 'user'

    }
}

And following is the error I am getting

| Error 2013-05-30 00:08:15,583 [elasticsearch[index]-pool-6-thread-2] ERROR index.IndexRequestQueue  - Failed bulk item: MapperParsingException[object mapping for [comment] tried to parse as object, but got EOF, has a concrete value been provided to it?]

I have looked through many posts on internet but I am unable to solve this issue!! So far my guess is that this may be due to my two variable with mapping type:"Text" Any help will be really appreciated.

I am using following repos as of now

mavenRepo "https://oss.sonatype.org/content/repositories/snapshots/"
        mavenRepo 'https://repo.springsource.org/libs-snapshot/'
        mavenRepo "http://maven.springframework.org/milestone/"

Following is the debug information I am getting after turning it on for ES

2013-05-30 18:26:11,157 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Retrieved index settings
2013-05-30 18:26:11,158 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Installing mappings...
2013-05-30 18:26:11,163 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Index com.ecw.wellness does not exists, initiating creation...
2013-05-30 18:26:11,163 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Waiting at least yellow status on com.ecw.wellness ...
2013-05-30 18:28:07,884 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Index com.ecw.wellness already exists, skip index creation.
2013-05-30 18:28:07,885 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - [com.ecw.wellness.answer] => {com.ecw.wellness.answer={properties={answer={type=string, include_in_all=true, term_vector=with_positions_offsets}, votes={type=object}, dateCreated={type=date, include_in_all=true}, lastUpdated={type=date, include_in_all=true}, question={type=object}}}}
2013-05-30 18:34:13,817 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Index com.ecw.wellness does not exists, initiating creation...
2013-05-30 18:34:13,818 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - Waiting at least yellow status on com.ecw.wellness ...
Sap
  • 5,197
  • 8
  • 59
  • 101

1 Answers1

1

EDIT:

I've found out what was the original bug: primitive types (ie: the int vote property in your Comment domain) are mapped as "object" by the plugin in ES, but the property is not serialized as an object so ES don't know how to handle it. Typing the vote property as Integer vote will make it work. I've filed an issue on the github repository for that: https://github.com/mstein/elasticsearch-grails-plugin/issues/61

Original answer (enhanced):

What version of the plugin are you using? The one from the grails repository or directly from the github repository? Anyway, could you try to pull the 0.20.6.1-SNAPSHOT version of the plugin that just magically appeared on the grails central repository?

runtime ":elasticsearch:0.20.6.1-SNAPSHOT"

Note: If you are not using the local mode and have your own ElasticSearch instance running, try to match the version number of the grails plugin : 0.20.6.

Also, if the plugin hangs during startup using the node mode, it may mean that it fails to discover automatically the ES cluster. In that case try to use the transport mode instead. FYI, the grails ES plugin will use the address localhost:9300 by default, but this is configurable (see the plugin documentation for that).

mstein
  • 56
  • 3
  • I was originally using 'runtime ":elasticsearch:0.17.8.1"'. After I tried using 20.6.0 SNAPSHOT my server hangs at " Running Grails application" and never moves ahead. – Sap May 30 '13 at 11:06
  • I have edite the original question and added the current maven repos i have. – Sap May 30 '13 at 11:12
  • I installed it again using grails install-plugin command and still it's stuck at "| Running Grails application" message from last 20 minutes! – Sap May 30 '13 at 11:38
  • You're using the default configuration (local node) or are you using an external elastic search instance? If it is a local node, you may have to reset (delete) the data folder of the ES node and re-index, as the 0.20.6-SNAPSHOT may have some difference in the mappings used – mstein May 30 '13 at 11:55
  • So sorry, I started using elasticsearch from last night, I deleted content of folder "elasticsearchhome/data" is that correct? And while we are at it, if I want to run it in "node" mode must I run the elastic search from terminal? My apologies for asking question in a question but will really appreciate your answer – Sap May 30 '13 at 12:09
  • Nope, still stuck on "| Running Grails application" – Sap May 30 '13 at 12:12
  • Yes you have to launch elastic search separately if you want to use the node or transport mode. And the "data" folder to delete should be created in your project root. – mstein May 30 '13 at 12:31
  • And could you try to turn on the debug logging for the 'org.grails.plugins.elasticsearch.mapping' package to see if it is hanging on a peculiar instruction. `debug 'org.grails.plugins.elasticsearch.mapping'` in the log4j config of you Config.groovy – mstein May 30 '13 at 12:40
  • Please see the edit... is there anything else involved to run it in node mode apart from "elasticSearch.client.mode = 'node'" ? – Sap May 30 '13 at 13:01
  • Ok, try with the `0.20.6.1-SNAPSHOT` version of the plugin. – mstein May 30 '13 at 14:03
  • Ok, I just created a vanilla project with the 0.20.6.1-SNAPSHOT version and I don't seems to have that server hanging issue. Have you cleaned the data folder again? That being said, I've found out what was the original bug: primitive types (the `int vote` property for ie) are mapped as "object" by the plugin in ES, but the property is not serialized as an object so ES don't know how to handle it. Typing the vote property as `Integer vote` will should it work. I've filed an issue on the github repository. – mstein May 31 '13 at 09:59
  • As a matter of fact, I downloaded the latest 9.0.1 copy of ES which did not have the data dir and it still did not work but as soon as I reverted my version back to :elasticsearch:0.17.8.1 and changed the 'int' to 'Integer' things started working. – Sap May 31 '13 at 10:21
  • Now I am getting error after excuting the search "Property Comment.post is not mapped as [component], but broken search hit found. – Sap May 31 '13 at 10:24
  • So I assume that you switched to `node` mode, there may be a few thing to configure to make the cluster automatic discovery feature work properly, like making sure that your firewall allows the multicast traffic for instance. But you should try first to use a `transport` mode that will directly use inet address you give to it (`localhost:9300` is the default). And I'm not sure ES `0.90.1` will work with the plugin, as it uses the `0.20.6` java client, there may be breaking changes in the API in the latest client. – mstein May 31 '13 at 12:48
  • But what about "Property Comment.post is not mapped as [component], but broken search hit found" error? That I am getting in local mode – Sap Jun 01 '13 at 04:57
  • Can you please see this?http://stackoverflow.com/questions/16895112/elastic-searchgrails-throwing-npe – Sap Jun 03 '13 at 10:57