|
|
|
[
Permlink
| « Hide
]
Maurice Nicholson - 26/Feb/08 03:23 PM
So you have configured a JDBC store for Compass?
Yes :
<compass-core-config xmlns="http://www.opensymphony.com/compass/schema/core-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opensymphony.com/compass/schema/core-config http://www.opensymphony.com/compass/schema/compass-core-config.xsd <compass name="default"> <connection> The name of table it's trying to create comes from the default alias for your domain class, which is typically "ALIAS" + domainClassName + "ALIAS" for historical reasons.
I've just commited a new feature (and made a release of the 0.4-SNAPSHOT version) that allows you to override the default alias with one of your choosing. It works like this: class MyClass {
static searchable = {
alias "myclass" // overrides the default alias with one you choose
// .. other searchable mapping config if you need it
}
// .. properties etc
}
This should allow you to set a shorter alias than the default and therefore make the table name shorter. Want to try it and report back? Maurice, do you think that it make sense to get back to the default alias name that Compass gives for mapped classes, which is the classname? I am guessing that you did it because there wasn't exclude-from-all feature, but I don't think a lot of people would want to do it, and this feature will be available in 2.0.
Anyhow, now with the support to control the alias name, they can put an obscure name if they choose to. yes I you're absolutely right Shay!
That was reason for choosing the silly generated alias we have now. Now people can obfuscate the alias themselves it does make more sense to use the basic class name as the default alias again. But personally I prefer to have exclude-alias-from-all on by default, and provide an option to turn it off, so for the sake of consistency in plugin search results I would prefer to implement the two together. It is a good question if the exclude alias from all should be on by default. From what I have seen in how people use Compass, they like the ability to search for "customer" and get all the customers back. Then they can do things like: "+customer +maurice" and other advance search options.
With the plugin as it stands at the moment one could just do Customer.search("maurice") to achieve the same thing
Away from the plugin I've used Compass searchable-constants for this, and that has the additional benefit that you can can choose some other string, even an obfuscated one if you like. The plugin supports searchable-constants internally but does not expose an API yet but it could be as simple as: class City {
static searchable = {
constant "location"
// other contstants and config
}
// ...
}
so that would work across the whole index like searchableService.search("+location +paris"). Cities are a nice example actually. Consider a large database of cities and then a search for "new york city": with exclude-alias-from-all turned off it returns many irrelevant results. I've tended to avoid having the alias as part of the searchable data so as to try to make search results as relevant as possible. I guess we both have our own differing opinions about this Exposing the constant config option should be trivial. Agreed, I prefer the constant solution as well as it provides more fine grained control. But, the question is out of the box experience, and it seems to me that having the alias as part of all out of the box is better.
Lets take it to the mailing list, and I will post a blog post asking as well. If people are for excluding the alias by default, I can add it as a Compass default as well. Ok, I'll send an email tonight and you make a post... let's see what happens
And I couldn't resist implementing the "constants" feature already: http://jira.codehaus.org/browse/GRAILSPLUGINS-260 Great feature!. I will post something now. Just looking at the docs, is there an option to configure index, store, and all the different aspects you can with constant?
Hmm, ok let's discuss this over at http://jira.codehaus.org/browse/GRAILSPLUGINS-260
once it's possible to define the sub-index in the searchable closure, this issue should be closed
Resolved in 0.5 branch thanks to Compass 2.0 upgrade
You can install the 0.5-SNAPSHOT from http://svn.codehaus.org/grails-plugins/grails-searchable/branches/0_5/grails-searchable-0.5-SNAPSHOT.zip but note that it is Java 5 only until I wrap up the 0.4.1 release The documentation for defining the sub-index in the searchable closure is here http://grails.org/Searchable+Plugin+-+Mapping#SearchablePlugin-Mapping-MappingDSL |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||