官网: http://www.elasticsearch.org

中文资料:http://www.learnes.net/

.Net驱动: http://nest.azurewebsites.net/

 

教程: http://www.jianshu.com/p/05cff717563c

 

三级: 索引/类型/ID或操作符

对应: 数据库/表/ID

配置

启动服务: /es/elasticsearch -d 

添加认证: http://segmentfault.com/a/1190000002803609

用户名: admin , admin_pw

 

关闭: curl -XPOST http://localhost:9200/_cluster/nodes/_shutdown

关闭某一个索引: curl -XPOST http://localhost:9200/_cluster/nodes/[某一个索引]/_shutdown

查看索引: curl -XGet http://localhost:9200/_cluster/nodes

插件

Head

elasticsearch/bin/plugin -install mobz/elasticsearch-head

http://localhost:9200/_plugin/head/

 

Docker 安装 head

高版本的需要用新的方式安装 head

https://www.cnblogs.com/aubin/p/8018081.html

分词

IK官网:https://github.com/medcl/elasticsearch-analysis-ik

安装IK:bin/plugin -install medcl/elasticsearch-analysis-ik  

 

安装分词需要 Jdk7,Maven,Git,在最新的ES(1.7.1)上,网上的文章大部分都是错的。正确方法: 

http://my.oschina.net/xiaohui249/blog/232784

http://www.360doc.com/content/15/0114/13/16070877_440673208.shtml

如果这两篇文章存在有冲突的地方,使用后者。

步骤:

1.安装Jdk7,然后,再运行: set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_80\bin

注意:安装的Jdk版本一定要和服务器使用的JRE版本一致。否则ES启动后,不可使用。

2.安装 Maven,Git

3.进入 D:\ik ,运行: clone https://github.com/medcl/elasticsearch-analysis-ik

4.进入 D:\ik\elasticsearch-analysis-ik

5.运行:mvn clean package

6.生成的 jar 在 D:\ik\elasticsearch-analysis-ik\target\releases\elasticsearch-analysis-ik-1.4.0.zip , 其它的 jar 全是扯蛋。把它解出来。

附上链接: 百度网盘下载:elasticsearch-analysis-ik-1.4.0.zip

7. 把 解压缩的jar 拷贝到: ES_HOME/plugins/analysis-ik

8. 将下载目录中的ik目录拷贝到ES_HOME/config目录下面。

9.打开ES_HOME/config/elasticsearch.yml文件,在文件最后加入如下内容

index:
  analysis:                   
    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

或:

index.analysis.analyzer.default.type: ik

10. 重新启动ES

11. 建一个索引,测试: 

 

curl -XPut 'http://localhost:9200/index/_analyze?analyzer=ik&pretty=true' -d '
{
"text":"世界如此之大"
}'

 

 

Maven

安装教程:http://jingyan.baidu.com/article/1709ad808ad49f4634c4f00d.html

官网:http://maven.apache.org/download.cgi

Git

下载:http://www.git-scm.com/download/win

过程

1. 创建索引:  Put ~/index

2. 获取所有Index: Get ~/_aliases

3. 创建别名: Put ~/<Index>/_alias/<Index_Alias>

4. 创建模板: Put  ~/<index>/_mapping/<type>  {type: {properties: { "列": { type:"string" }, "列2" : { type:  { Id: { type: "int"} , Name: { type: "string"} } } }}} 

对于《列2》来说,是一个对象类型,它可以是对象,也可以是对象数组。

更复杂的实例:

{
  "hr": {
    "properties": {
      "ResumeName": {
        "type": "string"
      },
      "Source": {
        "type": "integer"
      },
      "PersonInfo": {
        "properties": {
          "Name": {
            "type": "string",
            "analyzer": "ik",
            "include_in_all": true
          },
          "Sex": {
            "type": "integer",
            "analyzer": "ik",
            "include_in_all": true
          },
          "BirthDay": {
            "type": "date",
            "analyzer": "ik",
            "include_in_all": true
          },
          "Mobile": {
            "type": "string"
          },
          "StartWorkAt": {
            "type": "date",
            "analyzer": "ik",
            "include_in_all": true
          },
          "LiveCity": {
            "type": "string",
            "analyzer": "ik",
            "include_in_all": true
          },
          "JobWantedStatus": {
            "type": "integer",
            "analyzer": "ik",
            "include_in_all": true
          },
          "NativePlace": {
            "type": "string"
          },
          "MonthlySalary": {
            "type": "integer"
          },
          "YearSalary": {
            "type": "integer"
          },
          "National": {
            "type": "integer"
          },
          "IDCarNumber": {
            "type": "string"
          },
          "Height": {
            "type": "integer"
          },
          "MaritalStatus": {
            "type": "integer"
          },
          "WxNumber": {
            "type": "string"
          },
          "QqNumber": {
            "type": "integer"
          },
          "LiveAddress": {
            "type": "string"
          },
          "HomePage": {
            "type": "string"
          }
        }
      },
      "Intention": {
        "properties": {
          "Keyword": {
            "type": "string"
          },
          "SelfEvaluation": {
            "type": "string"
          },
          "ExpectWorkIn": {
            "type": "string",
            "analyzer": "ik",
            "include_in_all": true
          },
          "IndustryID": {
            "type": "integer"
          },
          "IndustryName": {
            "type": "string"
          },
          "PositionID": {
            "type": "integer"
          },
          "PositionName": {
            "type": "string"
          },
          "Nature": {
            "type": "integer"
          },
          "ExpectSalary": {
            "type": "integer",
            "analyzer": "ik",
            "include_in_all": true
          },
          "ArriveAt": {
            "type": "date"
          }
        }
      },
      "Education": {
        "properties": {
          "StartAt": {
            "type": "date"
          },
          "EndAt": {
            "type": "date"
          },
          "School": {
            "type": "string"
          },
          "Major": {
            "type": "string",
            "analyzer": "ik",
            "include_in_all": true
          },
          "Education": {
            "type": "integer",
            "analyzer": "ik",
            "include_in_all": true
          },
          "Remark": {
            "type": "string"
          },
          "IsForeign": {
            "type": "boolean"
          }
        }
      },
      "Experience": {
        "properties": {
          "StartAt": {
            "type": "date"
          },
          "EndAt": {
            "type": "date"
          },
          "Corporation": {
            "type": "string"
          },
          "IndustryID": {
            "type": "integer"
          },
          "IndustryName": {
            "type": "string"
          },
          "Size": {
            "type": "integer"
          },
          "Nature": {
            "type": "integer"
          },
          "PositionID": {
            "type": "integer"
          },
          "PositionName": {
            "type": "string"
          },
          "Remark": {
            "type": "string"
          },
          "WorkTimeType": {
            "type": "integer"
          }
        }
      },
      "Train": {
        "properties": {
          "StartAt": {
            "type": "date"
          },
          "EndAt": {
            "type": "date"
          },
          "TrainingInstitution": {
            "type": "string"
          },
          "TrainingPlace": {
            "type": "string"
          },
          "TrainingCourse": {
            "type": "string"
          },
          "Certificate": {
            "type": "string"
          },
          "Remark": {
            "type": "string"
          }
        }
      },
      "Language": {
        "properties": {
          "LanguageType": {
            "type": "integer"
          },
          "Degree": {
            "type": "integer"
          },
          "Level": {
            "type": "string"
          }
        }
      },
      "AdditionalInfo": {
        "properties": {
          "Subject": {
            "type": "string"
          },
          "Content": {
            "type": "string"
          }
        }
      },
      "Certificate": {
        "properties": {
          "Name": {
            "type": "string"
          },
          "GetAt": {
            "type": "date"
          },
          "Score": {
            "type": "string"
          }
        }
      },
      "Project": {
        "properties": {
          "StartAt": {
            "type": "date"
          },
          "EndAt": {
            "type": "date"
          },
          "Name": {
            "type": "string",
            "analyzer": "ik",
            "include_in_all": true
          },
          "Development": {
            "type": "string"
          },
          "Remark": {
            "type": "string"
          },
          "MyDuty": {
            "type": "string"
          }
        }
      },
      "ItSkill": {
        "properties": {
          "Name": {
            "type": "string"
          },
          "UseTime": {
            "type": "string"
          },
          "Degree": {
            "type": "integer"
          }
        }
      },
      "TxtContent": {
        "type": "string",
        "analyzer": "ik",
        "include_in_all": true
      },
      "OtherContent": {
        "type": "string",
        "analyzer": "ik",
        "include_in_all": true
      }
    }
  }
}
Es模板

相关文章:

  • 2022-12-23
  • 2021-06-22
  • 2021-04-13
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-08-28
  • 2021-04-20
相关资源
相似解决方案