标签:配置 art solr rest select style products tty 安装
Download
http://lucene.apache.org/solr/downloads.html
Apache Solr入门基础——Windows下安装与配置
https://blog.csdn.net/wsxsxz_/article/details/62048595
Start
$ cd E:\01_SOFT\Java\solr-8.2.0\bin
$ solr start
solr start –p <端口号> 单机版启动solr服务 solr restart –p <端口号> 重启solr服务 solr stop –p <端口号> 关闭solr服务 solr create –c <name> 创建一个core实例
访问
http://localhost:8983/solr
创建core命名为jcg
solr create -c jcg -d basic_configs
需要从$SOLR_HOME/solr/configsets/sample_techproducts_configs/conf/ 下拷贝文件
从CSV导入数据
cd E:\01_SOFT\Java\solr-8.2.0\example\exampledocs
$ java -Dtype=text/csv -Durl=http://localhost:8983/solr/jcg/update -jar post.jar books.csv
JSON导入
$ java -Dtype=application/json -Durl=http://localhost:8983/solr/jcg/update -jar post.jar
books.json
浏览器查询
http://localhost:8983/solr/jcg/select?q=name:"game"
http://localhost:8983/solr/jcg/select?q=name:"*of"
http://localhost:8983/solr/jcg/select?q=*&fq=price:[0 TO 6]
从mysql导入数据
Solr DataImportHandler 配置
https://www.cnblogs.com/llguanli/p/7028974.html
jar包
E:\01_SOFT\Java\solr-8.2.0\dist
log
E:\01_SOFT\Java\solr-8.2.0\server\logs
solrconfig.xml
... <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*\.jar" /> <lib dir="${solr.install.dir:../../../..}/dist/" regex="mysql-.*\.jar" /> <requestHandler name="/dataimport" class="solr.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler> </config>
data-config.xml
<?xml version="1.0" encoding="UTF-8" ?> <dataConfig> <dataSource type="JdbcDataSource" name="sqldb2" driver="com.mysql.jdbc.Driver" convertType="true" url="jdbc:mysql://127.0.0.1:3306/log" user="root" password="******"/> <document> <entity name="domain" dataSource="sqldb2" query="select id,ipdomain,domain,ip,rootdomain,ipinfo,domaininfo from domain" > <field name="id" column="id"/> <field name="ipdomain" column="ipdomain"/> <field name="domain" column="domain"/> <field name="ip" column="ip"/> <field name="rootdomain" column="rootdomain"/> <field name="ipinfo" column="ipinfo"/> <field name="domaininfo" column="domaininfo"/> </entity> </document> </dataConfig>
导入数据
http://localhost:8983/solr/#/jcg/dataimport//dataimport
访问
http://localhost:8983/solr/jcg/select?q=ipdomain:%22url.cn%22
返回xml格式
http://localhost:8983/solr/jcg/select?q=ipdomain:%22url.cn%22&wt=xml
[solr] - 索引数据删除
<delete><query>*:*</query></delete> <commit/>
使用solr将CSV/XML/DB/JSON数据发布为Rest Service
标签:配置 art solr rest select style products tty 安装
原文地址:https://www.cnblogs.com/sui84/p/11621273.html