Skip to content

Instantly share code, notes, and snippets.

@sandyxu
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandyxu/4a763b9b027a074cf398 to your computer and use it in GitHub Desktop.
Save sandyxu/4a763b9b027a074cf398 to your computer and use it in GitHub Desktop.
config elasticsearch and ik Analysis (Chinese word)

macos 10.10.1

Installation java (elasticsearch require)

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 选择 jdk-8u25-macosx-x64.dmg 下载

Installation elasticsearch

elasticsearch

Download and unzip the Elasticsearch official distribution.

cp ~/Downloads/elasticsearch /usr/share/elasticsearch

cd /usr/share/elasticsearch/

Run bin/elasticsearch on unix, or bin\elasticsearch.bat on windows.

Run curl -X GET http://localhost:9200/

or

brew install elasticsearch

==> Downloading https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.4.tar.gz ######################################################################## 100.0% ==> Caveats Data: /usr/local/var/elasticsearch/elasticsearch_xuch/ Logs: /usr/local/var/log/elasticsearch/elasticsearch_xuch.log Plugins: /usr/local/var/lib/elasticsearch/plugins/

To have launchd start elasticsearch at login: ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents Then to load elasticsearch now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist Or, if you don't want/need launchctl, you can just run: elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml ==> Summary /usr/local/Cellar/elasticsearch/1.3.4: 36 files, 30M, built in 5.0 minutes

添加ik插件用来中文分词

下载ik插件的地方很多,我选择从https://github.com/medcl/elasticsearch-analysis-ik

wget https://github.com/medcl/elasticsearch-analysis-ik/archive/v1.2.6.zip

unzip v1.2.6.zip  #get dir: elasticsearch-analysis-ik-1.2.6

cp elasticsearch-analysis-ik-1.2.6/config/ik  /usr/share/elasticsearch/config

edit /usr/share/elasticsearch/config/elasticsearch.yml like this:

path.conf: /usr/share/elasticsearch/config
path.plugins: /usr/share/elasticsearch/plugins


#################################### Plugin ###################################

# If a plugin listed here is not installed for current node, the node will not start.
#
#plugin.mandatory: mapper-attachments,lang-groovy

index:
  analysis:
    tokenizer:
      mmseg_maxword:
          type: mmseg
          seg_type: "max_word"
      mmseg_complex:
          type: mmseg
          seg_type: "complex"
      mmseg_simple:
          type: mmseg
          seg_type: "simple"
    analyzer:
      ik:
          alias: [ik_analyzer]
          type: org.elasticsearch.index.analysis.IkAnalyzerProvider
      ik_max_word:
          type: ik
          use_smart: false
      ik_smart:
          type: ik
          use_smart: true
      mmseg:
          alias: [news_analyzer, mmseg_analyzer]
          type: org.elasticsearch.index.analysis.MMsegAnalyzerProvider
      mmseg_maxword:
          type: custom
          filter: [lowercase]
          tokenizer: mmseg_maxword
      mmseg_complex:
          type: custom
          filter: [lowercase]
          tokenizer: mmseg_complex
      mmseg_simple:
          type: custom
          filter: [lowercase]
          tokenizer: mmseg_simple
#index.analysis.analyzer.default.type: mmseg
index.analysis.analyzer.default.type: ik

参考自 https://gist.github.com/jhjguxin/5e51ca18555a7fe9d641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment