首页 > 其他分享 >使用xml更新solr索引

使用xml更新solr索引

时间:2023-05-16 10:32:18浏览次数:53  
标签:xml false 05991 default solr 索引 add optional true


使用xml更新solr索引

Solr接受xml格式数据更新、提交、修改索引。

 

更新的Schema

不要混淆SCHEMA.XML

add/replace documents

 

Simple Example:

<!--[if !supportLists]-->·         <!--[endif]--><add>
<!--[if !supportLists]-->·         <!--[endif]-->  <doc>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="employeeId">05991</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="office">Bridgewater</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills">Perl</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills">Java</field>
<!--[if !supportLists]-->·         <!--[endif]-->  </doc>
<!--[if !supportLists]-->·         <!--[endif]-->  [<doc> ... </doc>[<doc> ... </doc>]]
 
 
</add>

注:多个文件,可以在一个单一的<add>命令指定。

optional属性为“add”

overwrite =“true”|“false” 默认是“true”,意味着新的文件具有相同的uniquekey取代以前添加的文件。

 

可选的属性“DOC”

boost = <float> — default is 1.0

这是一个方便的机制◦等同的刺激属性指定各个领域,支持规范(见下文)

optional属性为“field”

update = "add" | "set" | "inc"

boost = <float> — default is 1.0

◦NOTE: 确保规范启用 (omitNorms="false" in the schema.xml)

添加各种可选的属性文件的例子

Example of "add" with optional boost attribute:

<!--[if !supportLists]-->·         <!--[endif]--><add>
<!--[if !supportLists]-->·         <!--[endif]-->  <doc boost="2.5">
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="employeeId">05991</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="office" boost="2.0">Bridgewater</field>
<!--[if !supportLists]-->·         <!--[endif]-->  </doc>
 
 
</add>

 

Example of "add" with optional update attribute:

<!--[if !supportLists]-->·         <!--[endif]--><add>
<!--[if !supportLists]-->·         <!--[endif]-->  <doc>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="employeeId">05991</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="office" update="set">Walla Walla</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills" update="add">Python</field>
<!--[if !supportLists]-->·         <!--[endif]-->  </doc>
 
 
</add>

 

 

Example of "add" with optional update attribute to set multiple values on a multi-valued field:

<!--[if !supportLists]-->·         <!--[endif]--><add>
<!--[if !supportLists]-->·         <!--[endif]-->  <doc>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="employeeId">05991</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills" update="set">Python</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills" update="set">Java</field>
<!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills" update="set">Jython</field>
<!--[if !supportLists]-->·         <!--[endif]-->  </doc>
 
 
</add>

Example of "add" with optional update attribute to set a field to null (i.e. delete a field):

 

<!--[if !supportLists]-->·         <!--[endif]--><add><!--[if !supportLists]-->·         <!--[endif]-->  <doc><!--[if !supportLists]-->·         <!--[endif]-->    <field name="employeeId">05991</field><!--[if !supportLists]-->·         <!--[endif]-->    <field name="skills" update="set" null="true" /><!--[if !supportLists]-->·         <!--[endif]-->  </doc><!--[if !supportLists]-->·         <!--[endif]--></add> 
 
 
"commit" and "optimize"

 

提交操作将会在新的查询请求中提现。

 

Optional attributes for "commit" and "optimize"
waitFlush = "true" | "false" — default is true,等到索引更改刷新到磁盘
waitSearcher = "true" | "false" — default is true 等到新搜索打开注册主查询搜索,使变化可见
softCommit = "true" | "false" — default is false 执行一个软的提交,这将在一个更高效的方式刷新索引的“视图”,但是没有“磁盘”的保证。
 
Optional attributes for "commit"
expungeDeletes = "true" | "false" — default is false 合并段删除掉
 
Optional attributes for "optimize"
 
 
<!--[if !supportLists]-->·         <!--[endif]--><commit waitSearcher="false"/>
<!--[if !supportLists]-->·         <!--[endif]--><commit waitSearcher="false" expungeDeletes="true"/>
 
 
<!--[if !supportLists]-->·         <!--[endif]--><optimize waitSearcher="false"/>
 
 
<!--[if !supportLists]-->·         <!--[endif]-->


 

通过提交和commitwithin参数作为URL的一部分

curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<add><doc><field name="id">testdoc</field></doc></add>'

 

"delete" documents by ID and by Query

<!--[if !supportLists]-->·         <!--[endif]--><delete><id>05991</id></delete>
 
 
<delete><query>office:Bridgewater</query></delete>
 
 
 
<!--[if !supportLists]-->·         <!--[endif]--><delete>
<!--[if !supportLists]-->·         <!--[endif]-->  <id>05991</id><id>06000</id>
<!--[if !supportLists]-->·         <!--[endif]-->  <query>office:Bridgewater</query>
<!--[if !supportLists]-->·         <!--[endif]-->  <query>office:Osaka</query>
 
 
</delete>

参考网址

http://wiki.apache.org/solr/UpdateXmlMessages

 

 

标签:xml,false,05991,default,solr,索引,add,optional,true
From: https://blog.51cto.com/u_6687237/6282570

相关文章

  • 如何使用IndexOf方法获取JS对象数组中的索引
    获得数组里某一个对象的索引的最佳方法是什么呢?比如如下场景:varhello={hello:'world',foo:'bar'};varqaz={hello:'stevie',foo:'baz'}varmyArray=[];myArray.push(hello,qaz);现在我想得到hello属性值是stevie的对象的索引。在这个例......
  • xml解析技术
    dom解析技术:xml作用:存储数据,做配置信息,最后进行数据传输。xml最终被程序读取,解析里面的信息。 ......
  • 索引组织表 Index Organizied Table 索引组织表 Index Organizied Table
     CREATETABLEt1(idINTPRIMARYKEY,cINT)ENGINE=Memory;CREATETABLEt2(idINTPRIMARYKEY,cINT)ENGINE=InnoDB;INSERTINTOt1VALUES(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0);INSERTINTOt2VALUES(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(......
  • 魔术索引
    魔术索引。在数组A[0...n-1]中,有所谓的魔术索引,满足条件A[i]=i。给定一个有序整数数组,编写一种方法找出魔术索引,若有的话,在数组A中找出一个魔术索引,如果没有,则返回-1。若有多个魔术索引,返回索引值最小的一个。示例1:输入:nums=[0,2,3,4,5]输出:0说明:0下标的元素为0......
  • 报错问题:谷粒商城Access to XMLHttpRequest at 'http://localhost:88/api/sys/login'
    大概在P46P47,跟着配置后出现问题AccesstoXMLHttpRequestat'http://localhost:88/api/sys/login'fromorigin'http://localhost:8001'hasbeenblockedbyCORSpolicy: 上网查了一下,说是跨域的问题,检查了一会,有人说是nacos的命名空间的问题,也有人说是版本上的问题,大多......
  • WebApplicationInitializer究 Spring 3.1之无web.xml式 基于代码配置的servlet3.0应用
    大家应该都已经知道Spring3.1对无web.xml式基于代码配置的servlet3.0应用。通过spring的api或是网络上高手们的博文,也一定很快就学会并且加到自己的应用中去了。PS:如果还没,也可以小小参考一下鄙人的上一篇文章<<探Spring3.1之无web.xml式基于代码配置的servlet3.0应用>>。    ......
  • 几个主要搜索引擎(Google和百度、雅虎)的站内搜索代码
    几个主要搜索引擎(Google和百度、雅虎)的站内搜索代码,使用时只需要将代码里的"www.williamlong.info"替换成你的网址即可。<!--Google站内搜索开始--><formmethod=getaction="http://www.google.com/search"><inputtype=textname=q><inputtype=submitname=btnGvalue="......
  • MySQL学习日志十三,索引
    一、索引的作用1.提高查询速度2.确保数据的唯一性3.可以加速表和表之间的连接,实现表与表之间的参照完整性4.使用分组和排序子句进行数据检索时,可以显著减少分组和排序的时间5.全文检索字段进行搜索优化.二、分类1.主键索引(PrimaryKey)2.唯一索引(Unique)3.常规......
  • pom.xml详解
    <projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">&......
  • mysql8 json 索引总结
    表结构如下所示:CREATETABLE`test_json`(`id`bigintNOTNULLAUTO_INCREMENT,`name`varchar(32)NOTNULL,`age`intNOTNULL,`test_json_array`jsonNOTNULL,`test_json_object`jsonNOTNULL,`test_json_array_object`jsonNOTNULL,`custinfo......