Improved type related settings in Compass
It started with a thread in Compass forum. This turned out to be a new feature request in Compass, allowing for Compass to automatically set the index setting for a property mapping based on the type (if it is not explicitly set). Compass tries to adhere to “Conventions over Configuration” (which I like to name: “COC” :) ), but I guess it can always do better.
For example, most, if not all times, a number (such as int, float, …), should be stored in UN_TOKENIZED form. By default in Compass, if not setting the “index”, everything will be TOKENIZED. Now, with the latest Compass trunk, number types will be TOKENIZED. This also applies to Boolean, URI, URL types.
Last but not least, for numeric types, a specific format has been added named: sortable. This means that if you put it in the format tag for specific mapping definition, it will be stored in an internal sortable format, which makes thing much simpler.
March 26th, 2008 at 6:27 am
How do you specify the sortable format? Do you have to set it on each searchable property? Using annotations, how do you set it? Thanks. I’d like to set all numbers to be sortable by default, is that possible?
March 26th, 2008 at 6:36 am
You simply specify: test, or @SearchableProperty(format=”sortable”).
You can specify all the numbers to be sortable, but note that the internal string representation is not numeric, so it might not work for all cases when using queries.
March 26th, 2008 at 6:59 am
Meaning I cannot do this:
Btw, the error message I get with this is wrong,
org.compass.core.converter.ConversionException: Failed to parse date [200]
should be number, right?
March 26th, 2008 at 7:01 am
Argh:
<compass:converter name=”long” type=”org.compass.core.converter.basic.LongConverter”>
<compass:setting name=”format” value=”sortable”>
Snipped.
March 26th, 2008 at 7:06 am
Lets move this to the forum, ok?
March 26th, 2008 at 7:24 am
You’re rigth, so I did. :-)