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

Last change on this file since 323 was 323, checked in by duh, 12 years ago
  • fixed the issue with deploying the production war on tomcat (searchable / compass trying to write to /dev/null). Deployment now works perfectly without errors...
File size: 6.4 KB
RevLine 
[320]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}"
[323]33         *
34         * Checks if user.home points to /dev/null (which happens when deploying on tomcat) and set
35         * it to /home/tomcat if it is the case. Otherwise just use the user.home
[320]36     */
37    compassConnection = new File(
[323]38                sprintf("%s/.grails/projects/%s/searchable-index/%s",
39                        ((user.home == "/dev/null") ? "/home/tomcat" : user.home),
40                        appName,
41                        grailsEnv
42                )
[320]43    ).absolutePath
44
45    /**
46     * Any settings you wish to pass to Compass
47     *
48     * Use this to configure custom/override default analyzers, query parsers, eg
49     *
50     *     Map compassSettings = [
51     *         'compass.engine.analyzer.german.type': 'German'
52     *     ]
53     *
54     * gives you an analyzer called "german" you can then use in mappings and queries, like
55     *
56     *    class Book {
57     *        static searchable = { content analyzer: 'german' }
58     *        String content
59     *    }
60     *
61     *    Book.search("unter", analyzer: 'german')
62     *
63     * Documentation for Compass settings is here: http://www.compass-project.org/docs/2.1.0M2/reference/html/core-settings.html
64     */
65    compassSettings = [:]
66
67    /**
68     * Default mapping property exclusions
69     *
70     * No properties matching the given names will be mapped by default
71     * ie, when using "searchable = true"
72     *
73     * This does not apply for classes using "searchable = [only/except: [...]]"
74     * or mapping by closure
75     */
76    defaultExcludedProperties = ["password"]
77
78    /**
79     * Default property formats
80     *
81     * Value is a Map between Class and format string, eg
82     *
83     *     [(Date): "yyyy-MM-dd'T'HH:mm:ss"]
84     *
85     * Only applies to class properties mapped as "searchable properties", which are typically
86     * simple class types that can be represented as Strings (rather than references
87     * or components) AND only required if overriding the built-in format.
88     */
89    defaultFormats = [:]
90
91    /**
92     * Set default options for each SearchableService/Domain-class method, by method name.
93     *
94     * These can be overriden on a per-query basis by passing the method a Map of options
95     * containing those you want to override.
96     *
97     * You may want to customise the options used by the search method, which are:
98     *
99     * @param reload          whether to reload domain class instances from the DB: true|false
100     *                        If true, the search  will be slower but objects will be associated
101     *                        with the current Hibernate session
102     * @param escape          whether to escape special characters in string queries: true|false
103     * @param offset          the 0-based hit offset of the first page of results.
104     *                        Normally you wouldn't change it from 0, it's only here because paging
105     *                        works by using an offset + max combo for a specific page
106     * @param max             the page size, for paged search results
107     * @param defaultOperator if the query does not otherwise indicate, then the default operator
108     *                        applied: "or" or "and".
109     *                        If "and" means all terms are required for a match, if "or" means
110     *                        any term is required for a match
111     * @param suggestQuery    if true and search method is returning a search-result object
112     *                        (rather than a domain class instance, list or count) then a
113     *                        "suggestedQuery" property is also added to the search-result.
114     *                        This can also be a Map of options as supported by the suggestQuery
115     *                        method itself
116     *
117     * For the options supported by other methods, please see the documentation
118     * http://grails.org/Searchable+Plugin
119     */
120    defaultMethodOptions = [
121        search: [reload: false, escape: false, offset: 0, max: 10, defaultOperator: "and"],
122        suggestQuery: [userFriendly: true]
123    ]
124
125    /**
126     * Should changes made through GORM/Hibernate be mirrored to the index
127     * automatically (using Compass::GPS)?
128     *
129     * If false, you must manage the index manually using index/unindex/reindex
130     */
131    mirrorChanges = true
132
133    /**
134     * Should the database be indexed at startup (using Compass:GPS)?
135     *
136     * Possible values: true|false|"fork"
137     *
138     * The value may be a boolean true|false or a string "fork", which means true,
139     * and fork a thread for it
140     *
141     * If you use BootStrap.groovy to insert your data then you should use "true",
142     * which means do a non-forking, otherwise "fork" is recommended
143     */
144    bulkIndexOnStartup = true
145
146    /**
147     * Should index locks be removed (if present) at startup?
148     */
149    releaseLocksOnStartup = true
150}
151
152// per-environment settings
153environments {
154    development {
155        searchable {
156            // development is default; inherits from above
157        }
158    }
159
160    test {
161        searchable {
162            // disable bulk index on startup
163            bulkIndexOnStartup = false
164
165            // use faster in-memory index
166            compassConnection = "ram://test-index"
167        }
168    }
169
170    production {
171        searchable {
172            // add your production settings here
173        }
174    }
175}
Note: See TracBrowser for help on using the repository browser.