gpt4 book ai didi

grails - 在Grails和ElasticSearch中解码属性失败

转载 作者:行者123 更新时间:2023-12-02 14:41:28 24 4
gpt4 key购买 nike

我正在使用Grails 2.5.0和ElasticSearch 0.0.4.6!我有以下域类:

Class Library {
--- code omitted ---
static hasMany = [books:Book]
static searchable = true
--- code omitted ---
}

Class Book {
--- code omitted ---
static belongsTo = [library:Library]
static searchable = true
--- code omitted ---
}

我尝试搜索这样的书:
--- code omitted ---
def events = elasticSearchService.search(
{
query_string(fields: ["Name"],
query: query)
suggest : { suggest_mode: 'popular' }
})

render events as JSON

我收到以下错误:

ERROR unmarshall.DomainClassUnmarshaller - Error unmarshalling property 'library' of Class Book with id 2 Message: Property Book.library is not mapped as [component], but broken search hit found.

最佳答案

您需要将Book域的'library'属性设置为组件。

在您的书域中,替换以下代码

static searchable = true





static searchable = { library component: true }



有关更多详细信息,请参见 elastic plugin document

关于grails - 在Grails和ElasticSearch中解码属性失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33328009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com