|
1 | 1 | === Quick Start
|
2 | 2 |
|
| 3 | +* Install Elasticsearch using instructions from https://www.elastic.co/guide/en/elasticsearch/reference/5.4/gs-installation.html[here]. |
| 4 | +
|
| 5 | +* Just like any other Grails plugin, through the Grails Plugin center and Edit your project's +build.gradle+ file, by adding the plugin's dependency declaration: |
| 6 | +
|
| 7 | +---- |
| 8 | +dependencies { |
| 9 | + ... |
| 10 | + compile "org.grails.plugins:elasticsearch:2.4.0" |
| 11 | + ... |
| 12 | +} |
| 13 | +---- |
| 14 | + |
| 15 | +* Updated `application.yml` with default configurations: |
| 16 | +---- |
| 17 | +elasticSearch: |
| 18 | + datastoreImpl: hibernateDatastore |
| 19 | + client: |
| 20 | + mode: transport |
| 21 | + hosts: |
| 22 | + - {host: localhost, port: 9300} |
| 23 | + cluster.name: <ENTER CLUSTER NAME HERE> |
| 24 | +---- |
| 25 | +
|
| 26 | +In order debug Elasticsearch plugin, add `logger("grails.plugins.elasticsearch", DEBUG, ['STDOUT'], false)` in `logback.groovy file as following: |
| 27 | + |
| 28 | +---- |
| 29 | +import grails.util.BuildSettings |
| 30 | +import grails.util.Environment |
| 31 | +import org.springframework.boot.logging.logback.ColorConverter |
| 32 | +import org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter |
| 33 | +
|
| 34 | +import java.nio.charset.Charset |
| 35 | +
|
| 36 | +conversionRule 'clr', ColorConverter |
| 37 | +conversionRule 'wex', WhitespaceThrowableProxyConverter |
| 38 | +
|
| 39 | +// See http://logback.qos.ch/manual/groovy.html for details on configuration |
| 40 | +appender('STDOUT', ConsoleAppender) { |
| 41 | + encoder(PatternLayoutEncoder) { |
| 42 | + charset = Charset.forName('UTF-8') |
| 43 | +
|
| 44 | + pattern = |
| 45 | + '%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} ' + // Date |
| 46 | + '%clr(%5p) ' + // Log level |
| 47 | + '%clr(---){faint} %clr([%15.15t]){faint} ' + // Thread |
| 48 | + '%clr(%-40.40logger{39}){cyan} %clr(:){faint} ' + // Logger |
| 49 | + '%m%n%wex' // Message |
| 50 | + } |
| 51 | +} |
| 52 | +
|
| 53 | +def targetDir = BuildSettings.TARGET_DIR |
| 54 | +if (Environment.isDevelopmentMode() && targetDir != null) { |
| 55 | + appender("FULL_STACKTRACE", FileAppender) { |
| 56 | + file = "${targetDir}/stacktrace.log" |
| 57 | + append = true |
| 58 | + encoder(PatternLayoutEncoder) { |
| 59 | + pattern = "%level %logger - %msg%n" |
| 60 | + } |
| 61 | + } |
| 62 | + logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false) |
| 63 | + logger("grails.plugins.elasticsearch", DEBUG, ['STDOUT'], false) |
| 64 | + root(ERROR, ['STDOUT', 'FULL_STACKTRACE']) |
| 65 | +} |
| 66 | +else { |
| 67 | + root(ERROR, ['STDOUT']) |
| 68 | +} |
| 69 | +---- |
| 70 | + |
3 | 71 | ==== Default mapping
|
4 | 72 |
|
5 | 73 | To declare a domain class to be searchable, the simplest way is to define the following static property in the code:
|
|
0 commit comments