Home >Backend Development >PHP Tutorial >How to use Elasticsearch for on-site search after installing it on Windows?
I have a wnmp environment on Windows 10. Now I will install Elasticsearch 2.3.3 to try it out (do a site search). The following is a record of the process of installing Elasticsearch 2.3.3 after referring to some information from Baidu:
<code>windows 10上安装Elasticsearch过程记录 一、安装和配置Java JDK 1、下载:http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-windows-x64.exe 2、设置环境变量: (1)点击【系统变量】下的【新建】按钮 变量名: JAVA_HOME 变量值: C:\Program Files\Java\jdk1.8.0_92 (2)按照同样的方式创建系统变量classpath 变量名: classpath 变量值: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar (3)在已有的系统变量 path 的变量值的最后加入以下变量值 ;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin 3、查看是否安装成功 java -verison或javac -version 二、安装和配置Elasticsearch 1、下载:https://www.elastic.co/downloads/elasticsearch //我下载的2.3.3版本 2、解压到d:\elasticsearch-2.3.3目录 3、配置Elasticsearch (1)配置 config\elasticsearch.yml文件 cluster.name: lgs-es node.name: node-1 (2)配置 bin\elasticsearch.in.bat文件 set ES_MIN_MEM=4g set ES_MAX_MEM=4g 4、运行服务 双击 bin\elasticsearch.bat 运行 三、安装Elasticsearch插件 1、安装head插件(head是ES的web控制台。) bin/plugin.bat install mobz/elasticsearch-head 安装后在浏览器输入http://localhost:9200/_plugin/head/ 运行 2、安装kibana插件 (1)下载地址: https://www.elastic.co/downloads/kibana (2)解压到d:\kibana-4.5.1-windows目录 (3)配置config\kibana.yml文件 elasticsearch.url: "http://localhost:9200" (4)bin\kibana.bat //启动kibana (5)浏览器输入http://localhost:5601 3、安装sense插件(sense是ES的调试工具,可以方便地通过浏览器给ES集群发送各种请求。) bin/kibana plugin --install elastic/sense 4、安装marvel插件 (1)安装Marvel到Elasticsearch bin/plugin install license //先安装license插件 bin/plugin install marvel-agent (2)安装Marvel到Kibana bin/kibana plugin --install elasticsearch/marvel/latest (3)启动Elasticsearch和Kibana bin/elasticsearch bin/kibana (4)浏览器输入: http://localhost:5601/app/marvel 5、安装elasticsearch-analysis-ik插件(ik是中文分词插件。) a、安装elasticsearch-analysis-ik之前先安装maven (1)下载maven: https://maven.apache.org/download.cgi (2)解压到C:\Program Files (x86)\apache-maven-3.3.9 (3)新建环境变量: 变量名:MAVEN_HOME 变量值:C:\Program Files (x86)\apache-maven-3.3.9 (4)在PATH中加入maven的bin的路径 ;%MAVEN_HOME%\bin (5)在命令提示符输入mvn -v ,成功会显示相关信息。 b、安装elasticsearch-analysis-ik插件 (1)下载压缩包https://github.com/medcl/elasticsearch-analysis-ik (2)解压到d:\elasticsearch-analysis-ik-master (3)cd d:\elasticsearch-analysis-ik-master (4)mvn package //用maven打包 (5)在elasticsearch-2.3.3\config和elasticsearch-2.3.3\plugins目录下都新建一个ik文件夹 (6)把打包生成的zip文件D:\elasticsearch-analysis-ik-master\target\releases\elasticsearch-analysis-ik-1.9.3.zip拷贝到plugins/ik下,并解压。 (7)分词库(D:\elasticsearch-analysis-ik-master\config中的内容)放到config/ik目录下 (8)重启es,测试http://localhost:9200/_analyze? analyzer=ik&pretty=true&text=java%E9%AB%98%E7%BA%A7%E5%B7%A5%E7%A8%8B%E5%B8%88 </code>
Question:
1. In addition to the plug-ins installed above, what other commonly used plug-ins need to be installed?
2. Now that I have reached the last step of the above installation record, what should I do next and how to do it?
I have a wnmp environment on Windows 10. Now I will install Elasticsearch 2.3.3 to try it out (do a site search). The following is a record of the process of installing Elasticsearch 2.3.3 after referring to some information from Baidu:
<code>windows 10上安装Elasticsearch过程记录 一、安装和配置Java JDK 1、下载:http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-windows-x64.exe 2、设置环境变量: (1)点击【系统变量】下的【新建】按钮 变量名: JAVA_HOME 变量值: C:\Program Files\Java\jdk1.8.0_92 (2)按照同样的方式创建系统变量classpath 变量名: classpath 变量值: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar (3)在已有的系统变量 path 的变量值的最后加入以下变量值 ;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin 3、查看是否安装成功 java -verison或javac -version 二、安装和配置Elasticsearch 1、下载:https://www.elastic.co/downloads/elasticsearch //我下载的2.3.3版本 2、解压到d:\elasticsearch-2.3.3目录 3、配置Elasticsearch (1)配置 config\elasticsearch.yml文件 cluster.name: lgs-es node.name: node-1 (2)配置 bin\elasticsearch.in.bat文件 set ES_MIN_MEM=4g set ES_MAX_MEM=4g 4、运行服务 双击 bin\elasticsearch.bat 运行 三、安装Elasticsearch插件 1、安装head插件(head是ES的web控制台。) bin/plugin.bat install mobz/elasticsearch-head 安装后在浏览器输入http://localhost:9200/_plugin/head/ 运行 2、安装kibana插件 (1)下载地址: https://www.elastic.co/downloads/kibana (2)解压到d:\kibana-4.5.1-windows目录 (3)配置config\kibana.yml文件 elasticsearch.url: "http://localhost:9200" (4)bin\kibana.bat //启动kibana (5)浏览器输入http://localhost:5601 3、安装sense插件(sense是ES的调试工具,可以方便地通过浏览器给ES集群发送各种请求。) bin/kibana plugin --install elastic/sense 4、安装marvel插件 (1)安装Marvel到Elasticsearch bin/plugin install license //先安装license插件 bin/plugin install marvel-agent (2)安装Marvel到Kibana bin/kibana plugin --install elasticsearch/marvel/latest (3)启动Elasticsearch和Kibana bin/elasticsearch bin/kibana (4)浏览器输入: http://localhost:5601/app/marvel 5、安装elasticsearch-analysis-ik插件(ik是中文分词插件。) a、安装elasticsearch-analysis-ik之前先安装maven (1)下载maven: https://maven.apache.org/download.cgi (2)解压到C:\Program Files (x86)\apache-maven-3.3.9 (3)新建环境变量: 变量名:MAVEN_HOME 变量值:C:\Program Files (x86)\apache-maven-3.3.9 (4)在PATH中加入maven的bin的路径 ;%MAVEN_HOME%\bin (5)在命令提示符输入mvn -v ,成功会显示相关信息。 b、安装elasticsearch-analysis-ik插件 (1)下载压缩包https://github.com/medcl/elasticsearch-analysis-ik (2)解压到d:\elasticsearch-analysis-ik-master (3)cd d:\elasticsearch-analysis-ik-master (4)mvn package //用maven打包 (5)在elasticsearch-2.3.3\config和elasticsearch-2.3.3\plugins目录下都新建一个ik文件夹 (6)把打包生成的zip文件D:\elasticsearch-analysis-ik-master\target\releases\elasticsearch-analysis-ik-1.9.3.zip拷贝到plugins/ik下,并解压。 (7)分词库(D:\elasticsearch-analysis-ik-master\config中的内容)放到config/ik目录下 (8)重启es,测试http://localhost:9200/_analyze? analyzer=ik&pretty=true&text=java%E9%AB%98%E7%BA%A7%E5%B7%A5%E7%A8%8B%E5%B8%88 </code>
Question:
1. In addition to the plug-ins installed above, what other commonly used plug-ins need to be installed?
2. Now that I have reached the last step of the above installation record, what should I do next and how to do it?
1. There are so many plug-ins for ES. Because it is Java, many experts have written a lot of things. I guess you also need the pinyin plug-in for fuzzy search and pinyin search.
2. If your tag is Larvae, then you also need to install Larvae's ES plug-in. You can use the native https://github.com/elastic/elasticsearch-php or packaged by other developers. Then write the data into ES, and then construct various search statements. Implement search. .
Kibana does not need to be installed. This is used in conjunction with logstash to create a logging system. Sense depends on the situation. If it is not a cluster, there is no need. One head or HD is enough.
The first is the data index, which involves the synchronization issue between the database and es. If you use mysql, you can use the logstash
plug-in of jdbc
. If you use mongodb
, you can use mongo-connector
. Of course, if your data volume is small, you can consider saving the data directly into es, without the need for mysql or mongo.
es has clients such as php/python. You can develop an API based on this. The front-end submits a search query to the API for query, and the data is returned to the front-end.
There are still some pitfalls when it comes to Chinese search. You can go to github and search for medcl
. He is the official Chinese employee of es. He should be mainly responsible for the Chinese aspect and has added a lot of useful information to es. Chinese plug-in