source: trunk/grails-app/conf/Searchable.groovy @ 967

Last change on this file since 967 was 622, checked in by gav, 14 years ago

Apply bug fix for ticket #76.
Rename all instances of Lucene to Searchable.
Improved global directory config.
Add log levels for searchable plugin and compass.

File size: 6.2 KB
Line 
1import org.codehaus.groovy.grails.commons.ConfigurationHolder
2
3/**
4 * This {@link groovy.util.ConfigObject} script provides Grails Searchable Plugin configuration.
5 *
6 * You can use the "environments" section at the end of the file to define per-environment
7 * configuration.
8 *
9 * Note it is NOT required to add a reference to this file in Config.groovy; it is loaded by
10 * the plugin itself.
11 *
12 * Available properties in the binding are:
13 *
14 * @param userHome The current user's home directory.
15 *                 Same as System.properties['user.home']
16 * @param appName The Grails environment (ie, "development", "test", "production").
17 *                Same as System.properties['grails.env']
18 * @param appVersion The version of your application
19 * @param grailsEnv The Grails environment (ie, "development", "test", "production").
20 *                  Same as System.properties['grails.env']
21 *
22 * You can also use System.properties to refer to other JVM properties.
23 *
24 * This file is created by "grails install-searchable-config", and replaces
25 * the previous "SearchableConfiguration.groovy"
26 */
27searchable {
28
29    /**
30    * The location of the Compass index
31    *
32    * Examples: "/home/app/compassindex", "ram://app-index" or null to use the default
33    *
34    * The default is "${user.home}/.grails/projects/${app.name}/searchable-index/${grails.env}"
35    */
36    compassConnection = new File(ConfigurationHolder.config.globalDirs.searchableIndexDirectory).absolutePath
37
38    /**
39     * Any settings you wish to pass to Compass
40     *
41     * Use this to configure custom/override default analyzers, query parsers, eg
42     *
43     *     Map compassSettings = [
44     *         'compass.engine.analyzer.german.type': 'German'
45     *     ]
46     *
47     * gives you an analyzer called "german" you can then use in mappings and queries, like
48     *
49     *    class Book {
50     *        static searchable = { content analyzer: 'german' }
51     *        String content
52     *    }
53     *
54     *    Book.search("unter", analyzer: 'german')
55     *
56     * Documentation for Compass settings is here: http://www.compass-project.org/docs/2.1.0M2/reference/html/core-settings.html
57     */
58    compassSettings = [:]
59
60    /**
61     * Default mapping property exclusions
62     *
63     * No properties matching the given names will be mapped by default
64     * ie, when using "searchable = true"
65     *
66     * This does not apply for classes using "searchable = [only/except: [...]]"
67     * or mapping by closure
68     */
69    defaultExcludedProperties = ["password"]
70
71    /**
72     * Default property formats
73     *
74     * Value is a Map between Class and format string, eg
75     *
76     *     [(Date): "yyyy-MM-dd'T'HH:mm:ss"]
77     *
78     * Only applies to class properties mapped as "searchable properties", which are typically
79     * simple class types that can be represented as Strings (rather than references
80     * or components) AND only required if overriding the built-in format.
81     */
82    defaultFormats = [:]
83
84    /**
85     * Set default options for each SearchableService/Domain-class method, by method name.
86     *
87     * These can be overriden on a per-query basis by passing the method a Map of options
88     * containing those you want to override.
89     *
90     * You may want to customise the options used by the search method, which are:
91     *
92     * @param reload          whether to reload domain class instances from the DB: true|false
93     *                        If true, the search  will be slower but objects will be associated
94     *                        with the current Hibernate session
95     * @param escape          whether to escape special characters in string queries: true|false
96     * @param offset          the 0-based hit offset of the first page of results.
97     *                        Normally you wouldn't change it from 0, it's only here because paging
98     *                        works by using an offset + max combo for a specific page
99     * @param max             the page size, for paged search results
100     * @param defaultOperator if the query does not otherwise indicate, then the default operator
101     *                        applied: "or" or "and".
102     *                        If "and" means all terms are required for a match, if "or" means
103     *                        any term is required for a match
104     * @param suggestQuery    if true and search method is returning a search-result object
105     *                        (rather than a domain class instance, list or count) then a
106     *                        "suggestedQuery" property is also added to the search-result.
107     *                        This can also be a Map of options as supported by the suggestQuery
108     *                        method itself
109     *
110     * For the options supported by other methods, please see the documentation
111     * http://grails.org/Searchable+Plugin
112     */
113    defaultMethodOptions = [
114        search: [reload: false, escape: false, offset: 0, max: 10, defaultOperator: "and"],
115        suggestQuery: [userFriendly: true]
116    ]
117
118    /**
119     * Should changes made through GORM/Hibernate be mirrored to the index
120     * automatically (using Compass::GPS)?
121     *
122     * If false, you must manage the index manually using index/unindex/reindex
123     */
124    mirrorChanges = false
125
126    /**
127     * Should the database be indexed at startup (using Compass:GPS)?
128     *
129     * Possible values: true|false|"fork"
130     *
131     * The value may be a boolean true|false or a string "fork", which means true,
132     * and fork a thread for it
133     *
134     * If you use BootStrap.groovy to insert your data then you should use "true",
135     * which means do a non-forking, otherwise "fork" is recommended
136     */
137    bulkIndexOnStartup = false
138
139    /**
140     * Should index locks be removed (if present) at startup?
141     */
142    releaseLocksOnStartup = true
143}
144
145// per-environment settings
146environments {
147    development {
148        searchable {
149            // development is default; inherits from above
150        }
151    }
152
153    test {
154        searchable {
155            // disable bulk index on startup
156            bulkIndexOnStartup = false
157
158            // use faster in-memory index
159            compassConnection = "ram://test-index"
160        }
161    }
162
163    production {
164        searchable {
165            // add your production settings here
166        }
167    }
168}
Note: See TracBrowser for help on using the repository browser.