solr 初探

注:要使用solr 6.0 必需要由java 1.8 及以上的环境html

1. 安装solr

从apache 官网下载solr软件包  并解压 tar zxf solr-x.y.z.tgzjava

我解压到了数据库

/home/kfh/software/solr 目录下apache

2. 运行 solr

进入bin目录  命令:json

$ bin/solr start

若是正常开启 能够打开浏览器 0.0.0.0:8983这个端口看到以下图 说明solr已经启动了:浏览器

 

 

中止solrbash

$ bin/solr stop -p 8983

查看solr运行状态app

$ bin/solr status

开启solr带示例配置ide

solr提供了示例,为了你们熟悉命令post

$ bin/solr -e techproducts

若是么有带示例,则须要你本身建立core

$ bin/solr create -c <name>

咱们会在core-selector 位置看到咱们建立的core

如今咱们由了core,本人理解core至关于es中的index,至关与数据库吧

可是尚未document,来建立document

$ bin/post -c gettingstarted example/exampledocs/*.xml
SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/gettingstarted/update...
Entering auto mode. File endings considered are
xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt
,log
POSTing file gb18030-example.xml (application/xml) to [base]
POSTing file hd.xml (application/xml) to [base]
POSTing file ipod_other.xml (application/xml) to [base]
POSTing file ipod_video.xml (application/xml) to [base]
POSTing file manufacturers.xml (application/xml) to [base]
POSTing file mem.xml (application/xml) to [base]
POSTing file money.xml (application/xml) to [base]
POSTing file monitor.xml (application/xml) to [base]
POSTing file monitor2.xml (application/xml) to [base]
POSTing file mp500.xml (application/xml) to [base]
POSTing file sd500.xml (application/xml) to [base]
POSTing file solr.xml (application/xml) to [base]
POSTing file utf8-example.xml (application/xml) to [base]
POSTing file vidcard.xml (application/xml) to [base]
14 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/gettingstarted/update...
Time spent: 0:00:00.153

而后咱们作一下简单的查询:

http://localhost:8983/solr/gettingstarted/select?q=video

能够看到查询出的结果是这样的:

是一个xml格式的结果

相关文章
相关标签/搜索