using custom Id column mapping with Searchable plugin
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 sea开发者_运维百科rchable 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?
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.
精彩评论