Solr Cookbook学习记录 - 第二章indexing your data

自动生成unique fields

1. 编辑schema.xml,添加如下内容:
<field name="id" type="uuid" indexed="true" stored="true" default="NEW" multiValued="false"/>
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="text" type="text_general" indexed="true" stored="true"/>
2. 定义uuid类型
<fieldType name="uuid" class="solr.UUIDField" indexed="true" />
3. 删除系统默认的uniqueKey,删除如下内容:
<uniqueKey>id</uniqueKey>
4. 添加如下内容测试:
<add>
    <doc>
        <field name="name">Test name</field>
        <field name="text">Test text contents</field>
    </doc>
</add>
5. 访问http://localhost:8983/solr/select?q=*:*&indent=true,可以看到
unique id值:b6f17c35-e5ad-4a09-b799-71580ca6be8a
----------------------------------------------------------------------------------------------------------------------------------------------------------
curl 'localhost:8983/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"1","user":{"add":"jack"}}]'
----------------------------------------------------------------------------------------------------------------------------------------------------------
优化主键索引

1. 编辑schema.xml,添加如下内容:
<fieldType name="string_pulsing" class="solr.StrField" postingsFormat="Pulsing40"/>
2. 修改id字段的类型
<field name="id" type="string_pulsing" indexed="true" stored="true" required="true" />
3. 编辑solrconfig.xml,添加如下内容:
<codecFactory class="solr.SchemaCodecFactory"/>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值