Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default analyzer #29

Open
msmolyak opened this issue Jun 6, 2012 · 2 comments
Open

Default analyzer #29

msmolyak opened this issue Jun 6, 2012 · 2 comments

Comments

@msmolyak
Copy link

msmolyak commented Jun 6, 2012

How can I set the default analyzer for the entire index?

@msmolyak
Copy link
Author

Added this code to the plugin for specifying the default analyzer in the local mode.

In the config.groovy:

elasticSearch {
...
/**
* Default analyzer to use in local mode
*/
defaultAnalyzer = "snowball"
...

In org.grails.plugins.elasticsearch.ClientNodeFactoryBean:

        case 'local':
            // Determines how the data is store (on disk, in memory, ...)
            def storeType = elasticSearchContextHolder.config.index.store.type
            if (storeType) {
                nb.settings().put('index.store.type', storeType as String)
                LOG.debug "Local ElasticSearch client with store type of ${storeType} configured."
            } else {
                LOG.debug "Local ElasticSearch client with default store type configured."
            }
            def queryParsers = elasticSearchContextHolder.config.index.queryparser
            if (queryParsers) {
                queryParsers.each { type, clz ->
                    nb.settings().put("index.queryparser.types.${type}".toString(), clz)
                }
            }
            // New code starts here
            if (elasticSearchContextHolder.config.defaultAnalyzer) {
                nb.settings().put('index.analysis.analyzer.default.type', elasticSearchContextHolder.config.defaultAnalyzer)
                LOG.debug "Setting default analyzer ${elasticSearchContextHolder.config.defaultAnalyzer}"
            }
            // New code ends here
            nb.local(true)
            break

@pengqiuyuan
Copy link

Excuse me, if I want to use Chinese word how to add such Ansj this, also like defaultAnalyzer = "ansj" Thank you so do https://github.com/ansjsun/ansj_seg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants