3

我有如下所示的域类

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'

    }

}

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'

    }
}

以下是我得到的错误

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

我浏览了互联网上的许多帖子,但我无法解决这个问题!到目前为止,我的猜测是,这可能是由于我的两个变量与映射type:"Text" 任何帮助将不胜感激。

到目前为止,我正在使用以下存储库

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

以下是我为 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 ...
4

1 回答 1

1

编辑

我发现了原始错误是什么:原始类型(即:int vote您的 Comment 域中的属性)被 ES 中的插件映射为“对象”,但该属性未序列化为对象,因此 ES 不知道如何处理它。键入 vote 属性Integer vote将使其工作。我为此在 github 存储库上提交了一个问题:https ://github.com/mstein/elasticsearch-grails-plugin/issues/61

原始答案(增强):

你用的是什么版本的插件?来自 grails 存储库还是直接来自 github 存储库?无论如何,你能不能尝试拉出刚刚神奇地出现在 grails 中央存储库中的插件的 0.20.6.1-SNAPSHOT 版本?

runtime ":elasticsearch:0.20.6.1-SNAPSHOT"

注意:如果您没有使用该local模式并且有自己的 ElasticSearch 实例正在运行,请尝试匹配 grails 插件的版本号:0.20.6

另外,如果插件在使用该node模式启动过程中挂起,可能意味着它无法自动发现 ES 集群。在这种情况下,请尝试改用该transport模式。仅供参考,grails ES 插件将localhost:9300默认使用该地址,但这是可配置的(请参阅插件文档)。

于 2013-05-30T09:22:09.553 回答