質問

Well I've been trying to get the searchable plugin to work with my current app, but there is one thing that bothers me:

Every search relies solely on the Lucene index.

And that leads to some disturbing problems (like this: http://jan-so.blogspot.mx/2009/04/eager-fetching-and-searchable-plugin-in.html). Basically, every one-to-many relationship will have a null value in a search result. To avoid that, you must make a lot of you Domains searchable, but well, that means that half of my database will be mapped into the Lucene index ... and that just sounds wrong.

I'm currently in development environment, so everything is loaded into memory, and Lucene makes java to use at least 40% more memory (a total of 1.2GB is used, and I have restricted what to include in it as much as possible with only and exclude).

So, can I stop it from relying just on Lucene index? I want it to search on the index but no to return only what the index has. Or is it really convenient to keep everything in the index (and thus doing it the searchable way) rather than making manual HQL queries?

役に立ちましたか?

解決 2

Well the answere is: Yes, you can retrieve all the information of an object without having to add it to the index.

For that you need to configure the plugin. First create the configuration file:

grails install-searchable-config

Then open it, find the defaultMethodOptions and change the reload param to true. Something like this:

defaultMethodOptions = [
    search: [reload: true, escape: false, offset: 0, max: 10, defaultOperator: "and"],
    suggestQuery: [userFriendly: true]
]

Now the search will reload the objects from the DB, but, as the config file states, the searches will become slower because now it needs to connect to the DB.

他のヒント

I think you will need to read up on using the component Keyword in the domain class definitions.

See here: http://grails.org/Searchable+Plugin+-+Mapping+-+Compass+concepts#Searchable Component

This way you can include the relevant information from your domain model without polluting the index with so many additional classes.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top