Solr配置文件说明
来源:互联网 发布:怎么查询端口号 server 编辑:程序博客网 时间:2024/06/08 07:53
为了满足多类型索引的建立和不同搜索需求,solr提供了MultiCore的机制。使用中,只需要通过配置Core相应的参数文件,就可以满足热扩展。本文主要介绍每个core下相应的关键配置文件和HttpGet请求接口。
1. Core的文件路径
test_core
|-- conf
|-- schema.xml ——配置索引域和数据域的对应关系
|-- solrconfig.xml ——配置solr处理规则,主要用于定制索引创建规则
|-- data-config.xml ——配置数据库查询语句
|-- data
|-- index
|-- tlog
2. solrconfig.xml
主要是配置solr的索引创建、查询接口和缓存机制等配置。
3. schema.xml
schema.xml主要有三部分, <types>节点主要配置参数类型和索引分词器,大致如下,以下可复用性强
<types> <fieldtype name="int" class="solr.IntField" omitNorms="true"/> <fieldtype name="date" class="solr.DateField" omitNorms="true"/> <fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" /> <fieldtype name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/> <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/><fieldType name="float" class="solr.FloatField" omitNorms="true"/> <!--分词,也可以使用mmseg或者jcseg等中文分词器--> <fieldtype name="simpleSeg" class="solr.TextField"><analyzer><tokenizer class="org.apache.lucene.analysis.standard.StandardTokenizerFactory"/></analyzer></fieldtype></types>
<fields>节点主要是配置索引域和数据表域的映射关系,大致如下,这个节点一般要业务需求配置
还有几个零碎的搜索逻辑配置,主要是默认值设定
<!-- field to use to determine and enforce document uniqueness. --> <uniqueKey>docid</uniqueKey> <defaultSearchField>title</defaultSearchField> <!-- field for the QueryParser to use when an explicit fieldname is absent <copyField source="title" dest="title_autocomplete" /> 用于智能提示--> <!-- SolrQueryParser configuration: defaultOperator="AND|OR" <solrQueryParser defaultOperator="OR"/>--> <solrQueryParser defaultOperator="AND"/>
4. dataconfig.xml
其中,<dataSource>节点用于配置数据库连接属性,可以配置多个,通过name做区分,如下
<dataSource type="JdbcDataSource" name="ds-1" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/my" user="root" password="654321" batchSize="-1"/><dataSource type="JdbcDataSource" name="ds-2" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.0.0.1:3306/my" user="root" password="654321" batchSize="-1"/>
<document>节点下用于配置数据库查询语句,每个entity对应一个查询实体,为了满足join逻辑,可以使用entity嵌套,实例如下
<document name="meetyou"><!-- name指定标明alias --><!-- query: 查询数据库表符合记录数据 --> <!-- deltaQuery:增量索引 全量查询主键ID --> <!-- deltaImportQuery:增量索引 查询增量的数据 --> <!-- deletedPkQuery:增量删除索引 如果没有删除操作,可不配置该sql --> <entity name="my_community_topic" dataSource="ds-1" query="select * from community_topic where is_deleted=0 limit ${dih.request.length} offset ${dih.request.offset}" deltaQuery="select id from community_topic where published_date > '${dih.last_index_time}' and is_deleted=0 " deletedPkQuery="select id from community_topic where modified_date > '${dih.last_index_time}' and is_deleted=1 " deltaImportQuery="select * from community_topic where ID='${dih.delta.id}'" > <field column="id" name="docid"/> <field column="id" name="id"/> <field column="title" name="title"/> <field column="content" name="content"/> <field column="is_recommended" name="is_recommended"/> <field column="tag_id" name="tag_id"/> <field column="total_review" name="total_review"/> <!--分数,使用聚合函数,entity可以嵌套entity--> <!--<entity name="my_topic_score" dataSource="ds-2"query="select if(count(*)=0,1.0,score) AS score from topic_score where id=${my_community_topic.id}" <field column="score" name="qscore"/> </entity>--> </entity> </document>
5. 索引增删改的HTTPGet URL说明
基于solr,我们可以免去自己复写回调接口(特殊业务下还是需要的),下面罗列一些比较常用的接口
基本格式都是:"http://" + server + ":" + port + "/" + webapp + "/" + coreName + "/" + params
其中
①"http://" + server + ":" + port + "/" + webapp + "/" + coreName + "/select?q=**&wt=json"
http://localhost:8090/mysimplecn/test_core/select?q=%27%E5%9C%B0%27&wt=json
select表示查询语句,q是查询内容,可以指定查询字段,默认值配置在schema.xml;返回结果由wt指定使用json序列化,默认是XML格式
②"http://" + server + ":" + port + "/" + webapp + "/" + coreName + "/dataimport?command=status&indent=true&wt=json"
执行全量索引,comman=status用于返回状态码
③"http://" + server + ":" + port + "/" + webapp + "/" + coreName + "/dataimport?command=delta-import"
执行增量索引,solr会读取dataimport.xml文件中的last_index_time字段,获取上次索引的时间,然后执行deltaImportQuery,获取增量数据并建立索引
④"http://" + server + ":" + port + "/" + webapp + "/" + coreName + "/update?optimize=true"
索引优化,用于将多个索引合并,减少索引分段数,增快检索速度,可以使用curl定时触发
- Solr配置文件说明
- Solr配置文件说明
- Solr配置文件说明
- Solr配置文件说明
- Solr学习之二:Solr配置文件说明
- Solr schema配置文件字段说明
- (搜索引擎之solr) schema.xml 配置文件说明
- (搜索引擎之solr) schema.xml 配置文件说明
- Solr配置文件
- solr配置文件
- solr配置文件
- Solr之配置文件solr.xml。
- solr配置文件详解
- [搜索] Solr (二) 配置文件
- solr配置文件讲解
- solr配置文件解析
- 【solr】——配置文件
- Solr配置文件及SolrCloud
- Solr快速新建core流程
- PCIe体系结构导读--第9章 流量控制
- Oracle10g数据库备份与恢复总结4--Oracle备份与恢复之物理备份--OS物理备份
- 最强反编译工具 ida pro 6.6 x86 arm x64 f5全插件原始安装文件泄露版 + sdk_utils
- 一些重要的算法
- Solr配置文件说明
- js事件大全
- 简单介绍Enumeration接口
- 修路方案(次小生成树)
- python 学习笔记---匿名函数 装饰器 偏函数
- java.util.concurrent.locks callable带有返回值的线程【4】
- Codeforces 492B. Vanya and Lanterns 二分
- JAVA JDBC(MySQL)驱动源码分析
- 解决intellij idea 中adb not responding you can wait more