2010-07-06 62 views
2

ID列映射我有一個自定義的ID映射域類使用自定義與檢索插件

... 
... 
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列一起工作的可搜索插件,如果是的話,我在做什麼錯?

回答

2

自定義域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' 
    } 
    ... 
} 

我也可以通過添加行

來啓用config.groovy中的調試
debug 'grails.app', 
     'org.codehaus.groovy.grails.plugins.searchable' 

你的log4j的配置塊(你可能需要從錯誤塊刪除「org.codehaus.groovy.grails.plugins」行!) 這將讓你看到這個羅盤映射的插件生產。

Jim。