English 中文(简体)
Grails searchable plugin
原标题:

In my Grails app, I m using the Searchable plugin for searching/indexing. I want to write a Compass/Lucene query that involves multiple domain classes. Within that query when I want to refer to the id of a class, I can t simply use id because all classes have an id property. Currently, I work around this problem by adding the following property to a class Foo

public Long getFooId() {
    return id
}
static transients = [ fooId ]

Then when I want to refer to the id of Foo within a query I use fooId . Is there a way I can provide an alias for a property in the searchable mapping rather than adding a property to the class?

最佳回答

I finally discovered that this is the way to do it:

static searchable = {
    id: name  fooId 
}
问题回答

You can give a more specific name to your id property. See this page for how to do this.

Thanks! This would work really well, that is, if I could get past the OOM errors the app server seems to throw each time Searchable plugin is installed. These are bubbling up via :

org.compass.gps.CompassGpsException: Failed to index, execution exception; nested exception is java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space

Has anyone configured their Searchable.groovy in grails-app/conf to perform a strict file:/// or mmap:// only configuration using no heap, and indexing say once or twice per day? Search is beyond a nice to have - but the cost of using the database mirroring in Grails (with Oracle 10g) seems memory intensive.

Really small amount of domains to search (4) small database, maybe 1-2gb for this application.





相关问题
grails + gwt request handling via controllers

I am new to gwt. I am trying to integrate gwt+grails.Can anybody provide me a good example for handling the request using grails controllers and not a custom servlet.I will be really thankful if ...

Error loading the grails gwt module xml

I ve installed the plugin from this article by Peter http://www.cacoethes.co.uk/blog/groovyandgrails/the-command-pattern-w.... While compile time its not able to find the module file which is present ...

Sorting Objects Based on Custom Domain Class Methods

I have a domain class, in which I ve defined some methods which give the object a score based on different algorithms (eg. popularity). I now want to retrieve a list of these objects sorted by one of ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

Hibernate/GORM: collection was not processed by flush()

I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate....

热门标签