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

Last change on this file since 592 was 571, checked in by gav, 15 years ago

Start lucene mirroring and index after creating bootstrap data.

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