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