Solr自动生成ID
在Solr中,每一个索引,都要有一个唯一的ID,类似于关系型数据库表中的主键。为了方便创建索引,需要配置自动生成的ID,即UUID。
一、配置schema.xml文件
添加uuid字段类型,修改字段id的类型。
<field name="id" type="uuid" indexed="true" stored="true" required="true" multiValued="false" />
<fieldType name="uuid" class="solr.UUIDField" indexed="true" />
二、配置solrconfig.xml文件
添加更新策略配置,调用Solr中的UUIDUpdateProcessorFactory生成全局唯一的UUID。
<updateRequestProcessorChain name="uuid">
<processor class="solr.UUIDUpdateProcessorFactory">
<str name="fieldName">id</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.DistributedUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
配置requestHandler,保证dataimport和update操作都可以自动生成UUID。
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">tika-data-config.xml</str>
<str name="update.chain">uuid</str>
</lst>
</requestHandler> <requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">uuid</str>
</lst>
</requestHandler> <!-- for back compat with clients using /update/json and /update/csv -->
<requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler">
<lst name="defaults">
<str name="stream.contentType">application/json</str>
<str name="update.chain">uuid</str>
</lst>
</requestHandler>
<requestHandler name="/update/csv" class="solr.CSVRequestHandler">
<lst name="defaults">
<str name="stream.contentType">application/csv</str>
<str name="update.chain">uuid</str>
</lst>
</requestHandler> <requestHandler name="/update/extract"
startup="lazy"
class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
<str name="xpath">/xhtml:html/xhtml:body/descendant:node()</str>
<str name="capture">content</str>
<str name="fmap.meta">attr_meta_</str>
<str name="uprefix">attr_</str>
<str name="lowernames">true</str>
<str name="update.chain">uuid</str>
</lst>
</requestHandler>
经过以上配置之后,在进行索引的时候,就不需要指定ID了,Solr可自动生成ID字符串。
Solr自动生成ID的更多相关文章
- Solr4.0 如何配置使用UUID自动生成id值
原文链接http://blog.csdn.net/keepthinking_/article/details/8501058#comments 最近学习了Lucene,随便也学习了Solr,Solr规 ...
- mybatis多表查询,自动生成id
主要是在配置文件中,配置好所要包含的字段. 类关系:account----role,1对1 account包含role类 java类: public class Account{ private In ...
- ASP.NET 4.0 ListView等容器控件中获取ClientID值与HTML中自动生成ID字符串不一样问题。
ASP.NET 4.0 中 ClientIDMode的属性 可以设置获取不同ID格式的值. 项目中遇到的问题: 1.ListView1 ItemDataBound事件中,获取ClientID结果与自动 ...
- Elasticsearch 索引文档如何使用自动生成 Id?
一个文档的 _index . _type 和 _id 唯一标识一个文档. 我们可以提供自定义的 _id 值,或者让 index API 自动生成. 如果你的数据没有自然的 ID, Elasticsea ...
- oracle中利用trigger,sequence自动生成ID
http://zhanghong.iteye.com/blog/865937 1. 首先创建数据库表 SQL> create table customer( 2 id number(8) no ...
- 自动生成ID
public class IdUtil { /** * * @return 返回时间id,类似于20191217195622 */ public static String timeId(){ Dat ...
- 系统自动生成ID(比UUID.radom().tostring()要好看)
public class test1 { public static void main(String[] args) { char[] para = {'A','B','C','D','E','F' ...
- MySQL 之 数据库自动生成ID格式化编号(字符串格式化填充/拼接/时间)
# 用户账号:1-4位:入职年份:5-6位:入职月份:7-11位:员工入职顺序号 select concat( date_format(now(),'%Y'), date_format(now(),' ...
- solr亿万级索引优化实践-自动生成UUID
solr亿万级索引优化实践(三) 原创 2017年03月14日 17:03:09 本篇文章主要介绍下如何从客户端solrJ以及服务端参数配置的角度来提升索引速度. solrJ6.0提供的 ...
随机推荐
- 【动态规划】XMU 1030 苦恼的月下老人
题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1030 题目大意: 给定两个字符串的长度和内容,求最长公共子序列. 题目思路: [动态规 ...
- UVAlive3523 Knights of the Round Table(bcc)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18122 [思路] 点-双连通分量 求出bcc,判断每个bcc是否为 ...
- hdu-1010 dfs+剪枝
思路: 剪枝的思路参考博客:http://www.cnblogs.com/zibuyu/archive/2012/08/17/2644396.html 在其基础之上有所改进 题意可以给抽象成给出一个 ...
- 本地apt
Ubuntu建立本地源非常實用,很多服務器在局域網沒有網络或者網络很慢的情況下,或者需要批量安裝同样的軟件的時候,如果每一台服務器都去外網下載,是不是很慢,而且也不是一個運維工程師願意這麼幹的!那有什 ...
- IOS学习教程
http://edu.51cto.com/course/course_id-566.html
- ListView的优化
1. ListView须要设置adapter,它的item是通过adapter的方法getView(int position, View convertView, ViewGroup parent)获 ...
- NYOJ 980 格子刷油漆 动态规划
这道题目状态转移方程比较复杂,刚开始以为没这么多情况,看了好多大牛的博客再加上与同学讨论才看懂,写下心得. 因为起点不固定,所以我们一个一个来考虑,先从角上考虑,设三个数组来表示分别为D,A,Sum, ...
- cogs 线型网络(状压dp)
/* 需要好大的空间..... 而且lowbit理解的不是很好 先放到博客里 以后慢慢研究 */ #include<iostream> #include<cstdio> #in ...
- ASP.NET 中的返回按钮的实现【转】
返回上一页的这个东东在我们做项目的时候一般是用于填写完表单后确认的时候,有对原来输入的数据进行修改时用的,或者是因为网站为了方便浏览者而有心添加 的一个东东,一般这种功能的实现在ASP.net中都 ...
- 精通Django或Rails框架
Django是一个开放源代码的Web应用框架,由Python写成. Rubyon Rails 是一个用于开发数据库驱动的网络应用程序的完整框架.