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.

6 Responses to “Improved type related settings in Compass”

  1. Kjersti Berg Says:

    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?

  2. Shay Banon Says:

    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.

  3. Kjersti Berg Says:

    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?

  4. Kjersti Berg Says:

    Argh:
    <compass:converter name=”long” type=”org.compass.core.converter.basic.LongConverter”>
    <compass:setting name=”format” value=”sortable”>

    Snipped.

  5. Shay Banon Says:

    Lets move this to the forum, ok?

  6. Kjersti Berg Says:

    You’re rigth, so I did. :-)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>