solr 一些小问题记录(不断更新中)

1. solr的schema.xml主键的注意事项

    solr中主键必须是string类型的。

 

2. copyFiled和defaultSearchField配合使用,schema.xml如下配置:

<fields>
<field name="id" type="string" indexed="true" stored="false" multiValued="true"/>
<field name="name" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="address" type="text" indexed="true" stored="false" multiValued="true"/>
<field name="all" type="text" indexed="true" stored="false" multiValued="true"/>
</fields>

<copyField source="name" dest="all"/>
<copyField source="address" dest="all"/>

<defaultSearchField>all</defaultSearchField>

 采用上面的配置,all 非实际字段,他是name和address字段的拷贝,再将all设置为默认搜索字段,这样默认搜索时,会在name和address里面都搜索。

 

3. 索引全部导入、增量导入、索引删除的命令

全部导入:

http://localhost:8080/genelist/dataimport?command=full-import&commit=true&charset=utf-8

 增量导入:

http://localhost:8080/genelist/dataimport?command=delta-import&commit=true&charset=utf-8

 按照id删除索引:

http://localhost:8080/genelist/update/?stream.contentType=text/xml;charset=utf-8&commit=true&stream.body=<delete><id>123</id></delete>

 按照查询删除索引:(比如删除全部索引)

http://localhost:8080/genelist/update/?stream.contentType=text/xml;charset=utf-8&commit=true&stream.body=<delete><query>*:*</query></delete>

 以上命令还有很多选项和参数,使用时可以自己去查找。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SolrInputDocument是Solr客户端库的类,表示一个Solr文档。Solr文档是一个由字段组成的集合,每个字段都有一个名称和一个值。 SolrInputDocument可以用于更新Solr索引的文档。要更新文档,需要首先获取现有文档的信息,然后将所需的更改应用于SolrInputDocument对象,最后使用Solr客户端库将更新后的SolrInputDocument对象发送到Solr服务器。 以下是一个示例代码,演示如何使用SolrInputDocument更新Solr索引的文档: ```java // 创建一个SolrInputDocument对象 SolrInputDocument doc = new SolrInputDocument(); // 添加字段到SolrInputDocument对象 doc.addField("id", "123"); doc.addField("name", "John Smith"); doc.addField("age", 30); // 创建一个Solr客户端对象,连接到Solr服务器 HttpSolrClient solrClient = new HttpSolrClient.Builder("http://localhost:8983/solr").build(); // 发送SolrInputDocument对象到Solr服务器,更新索引 solrClient.add(doc); // 提交更改 solrClient.commit(); ``` 在上面的示例,我们首先创建了一个SolrInputDocument对象,并向其添加了三个字段。然后,我们使用Solr客户端库连接到Solr服务器,使用add方法将SolrInputDocument对象发送到服务器,并使用commit方法提交更改。 请注意,这只是一个简单的示例,实际上更新Solr索引需要更复杂的过程和逻辑。例如,如果要更新现有文档,则需要首先获取该文档的信息,然后将更改应用于获取的信息,并将更新后的信息发送到Solr服务器。此外,还需要处理需要删除的字段和需要添加的字段等其他信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值