elasticsearch安装和基础

下载安装

安装或升级JDK(Java SE Development Kit 8)

java -version
echo $JAVA_HOME

下载Elasticsearch程序压缩包并解压,以2.2.1为例:

curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.2.1/elasticsearch-2.2.1.tar.gz
tar -xvf elasticsearch-2.2.1.tar.gz
cd elasticsearch-2.2.1

分词插件

IK,找到对应的版本。
Mmseg

以daemon方式elasticsearch启动(需要非root账户)

bin/elasticsearch -d

Logstash启动

 bin/logstash -f config/jdbc.conf

其中jdbc.conf为配置文件。

名词解释

索引(index)

相当于SQL数据库的数据库(database)

类型(type)

相当于SQL数据库的数据表(table)

文档(document)

相当于SQL数据库的数据记录或行(record or row)

字段(Field)

相当于SQL数据库的数据列(column)

映像(mapping)

相当于SQL数据库的数据模式(schema)

权重(boosting)

用于增加权重,例如title^5表示分数(score)加到5倍

解析器(analyzer)

用于解析Index,包含一个Tokenizer。

Elasticsearch ships with a wide range of built-in analyzers, which can be used in any index without further configuration.
Analyzers are composed of a single Tokenizer and zero or more TokenFilters. The tokenizer may be preceded by one or more CharFilters. The analysis module allows you to register Analyzers under logical names which can then be referenced either in mapping definitions or in certain APIs.

POST _analyze
{
    "analyzer": "whitespace",
    "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

分词(tokenizer)

用于解析字符串,成为terms或tokens

A tokenizer receives a stream of characters, breaks it up into individual tokens (usually individual words), and outputs a stream of tokens.
Tokenizers are used to break a string down into a stream of terms or tokens. A simple tokenizer might split the string up into terms wherever it encounters whitespace or punctuation.

POST _analyze
{
  "tokenizer": "whitespace",
  "text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}

过滤器(filter)

建议(suggester)

用于搜索建议
一共有四种:

  • Term suggester
  • Phrase Suggester
  • Completion Suggester
  • Context Suggester
posted @ 2017-03-29 16:06  SubjectiveInitiative  阅读(179)  评论(0编辑  收藏  举报