将自定义 Id 列映射与可搜索插件结合使用

发布于 2024-09-08 11:43:30 字数 1105 浏览 12 评论 0原文

我有一个带有自定义 Id 映射的 Domain 类

...
...
String ensemblGeneId
    String ensemblTranscriptId
    String ensemblProteinId
    String proteinSequence
    String topologySequence
    String topologyRatio
    String description
    String geneName

    ..       
    ..                                     
    ..

    static mapping = {
        proteinSequence type:'text'
        topologySequence type:'text'    
        description type:'text' 
        id name:'ensemblProteinId', generator:'assigned'    
    }

我在使用可搜索插件进行此操作时遇到问题

我将以下内容添加到类中

    static searchable = {
    id name:'ensemblProteinId'
    except = ['topologySequence','proteinSequence']

}

数据插入完成后收到以下错误

2010-07-06 13:35:08,091 [http-8080-1] ERROR errors.GrailsExceptionResolver  - Id with path [$/Protein/id] for alias [Protein] not found
org.compass.core.engine.SearchEngineException: Id with path [$/Protein/id] for alias [Protein] not found

似乎它仍在尝试查找名为的列id 而不是名为ensemblProteinId 的列。

可搜索插件是否应该与自定义 id 列一起使用,如果是的话我做错了什么?

I have a Domain class with a custom Id mapping

...
...
String ensemblGeneId
    String ensemblTranscriptId
    String ensemblProteinId
    String proteinSequence
    String topologySequence
    String topologyRatio
    String description
    String geneName

    ..       
    ..                                     
    ..

    static mapping = {
        proteinSequence type:'text'
        topologySequence type:'text'    
        description type:'text' 
        id name:'ensemblProteinId', generator:'assigned'    
    }

i have a problem making this work with the searchable plugin

i add the following to the class

    static searchable = {
    id name:'ensemblProteinId'
    except = ['topologySequence','proteinSequence']

}

I receive the following error after the data insert is completed

2010-07-06 13:35:08,091 [http-8080-1] ERROR errors.GrailsExceptionResolver  - Id with path [$/Protein/id] for alias [Protein] not found
org.compass.core.engine.SearchEngineException: Id with path [$/Protein/id] for alias [Protein] not found

it seems like it still tries to find a column named id instead of a column named ensemblProteinId.

is the searchable plugin supposed to work with custom id columns, if so what am i doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-09-15 11:43:30

自定义域 ID 和可搜索插件似乎确实存在问题。作为解决方法,您可以使用此处记录的罗盘注释来映射类:

http:// /grails.org/Searchable+Plugin+-+Mapping+-+Compass+annotations

和此处:

http://www.compass-project.org/docs/2.1.4/reference/html/core-osem.html

所以你的类看起来像:

import org.compass.annotations.*
@Searchable(alias='Test')
...
class Test {
    @SearchableId
    String sampleId

    @SearchableProperty
    String sampleValue

    static mapping = {
        id name:'sampleId', generator: 'assigned'
    }
    ...
}

我还将通过将行添加

 debug  'grails.app',
        'org.codehaus.groovy.grails.plugins.searchable'

到 log4j 配置块来启用 config.groovy 中的调试(您可能需要从错误块中删除“org.codehaus.groovy.grails.plugins”行!)
这将使您看到插件正在生成的罗盘映射。

吉姆.

There does appear to be an issue with custom domain ids and the searchable plugin. As a work around you can map the class using the compass annotations documented here:

http://grails.org/Searchable+Plugin+-+Mapping+-+Compass+annotations

and here:

http://www.compass-project.org/docs/2.1.4/reference/html/core-osem.html

So your class looks something like:

import org.compass.annotations.*
@Searchable(alias='Test')
...
class Test {
    @SearchableId
    String sampleId

    @SearchableProperty
    String sampleValue

    static mapping = {
        id name:'sampleId', generator: 'assigned'
    }
    ...
}

I'd also enable the debugging in your config.groovy by adding the lines

 debug  'grails.app',
        'org.codehaus.groovy.grails.plugins.searchable'

to your log4j configuration block(you may need to remove the 'org.codehaus.groovy.grails.plugins' line from the error block!)
This will let you see the compass mappings the plugin is producing.

Jim.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文