具有“文本”的Grails弹性搜索插件制图 [英] Grails elasticsearch plugin with "text" mapping

查看:161
本文介绍了具有“文本”的Grails弹性搜索插件制图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有域类看起来像以下

  class Post {

String title
String body


// common
日期dateCreated
日期lastUpdated

// Mappings
static belongsTo = [用户:用户]
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'

}

}

 类评论{

字符串注释
int投票

// common
日期dateCreated
日期lastUpdated

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

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

}
}

以下是我得到的错误

  |错误2013-05-30 00:08:15,583 [elasticsearch [index] -pool-6-thread-2] ERROR index.IndexRequestQueue  - 失败的批量项:MapperParsingException [[comment]的对象映射试图解析为对象,但是得到EOF有具体的价值吗?] 

我无法解决这个问题!到目前为止,我的猜测是,这可能是由于我的两个变量与映射类型:文本
任何帮助将非常感激。



我现在正在使用以下repos。

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

以下是ES打开ES后获得的调试信息

  2013-05-30 18:26:11,157 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator  - 检索到的索引设置
2013-05 -30 18:26:11,158 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator - 安装映射...
2013-05-30 18:26:11,163 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator - 索引com.ecw.wellness不存在,启动创建...
2013- 05-30 18:26:11,163 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator - 至少在com.ecw.wellness等待黄色状态...
2013-05-30 18:28:07,884 [localhost -startStop-1] DEBUG mapping.SearchableClassMappingConfigurator - 索引com.ecw.wellness已经存在,跳过索引创建。
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不存在,启动创建...
2013-05-30 18:34:13,818 [localhost-startStop-1] DEBUG mapping.SearchableClassMappingConfigurator - 至少在com.ecw.wellness等待黄色状态。


解决方案

编辑



我已经发现原始的bug是什么:原始类型(即: int vote 评论域)由ES中的插件映射为对象,但该属性未作为对象进行序列化,因此ES不知道如何处理它。将投票属性键入整数投票将使其正常工作。
我已经在github存储库中提出了一个问题: https: //github.com/mstein/elasticsearch-grails-plugin/issues/61



原始答案(增强版): / p>

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

 code> runtime:elasticsearch:0.20.6.1-SNAPSHOT

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



此外,如果插件在启动期间使用节点挂起模式,这可能意味着它无法自动发现ES群集。在这种情况下,请尝试使用 transport 模式。 FYI,grails ES插件默认使用地址为 localhost:9300 ,但这是可配置的(请参阅插件文档)。


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

解决方案

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).

这篇关于具有“文本”的Grails弹性搜索插件制图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆