SOLR 可以执行 UPSERT 吗? [英] Can SOLR perform an UPSERT?

查看:36
本文介绍了SOLR 可以执行 UPSERT 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在 solr 中执行相当于 UPSERT(插入或更新,如果已经存在)的操作.我只知道什么不起作用,我阅读的 solr/lucene 文档没有帮助.这是我尝试过的:

I've been attempting to do the equivalent of an UPSERT (insert or update if already exists) in solr. I only know what does not work and the solr/lucene documentation I have read has not been helpful. Here's what I have tried:

curl 'localhost:8983/solr/update?commit=true' -H 'Content-type:application/json' -d '[{"id":"1","name":{"set":"steve"}}]'
{"responseHeader":{"status":409,"QTime":2},"error":{"msg":"Document not found for update.  id=1","code":409}}

我在一个请求中最多进行 50 次更新,并且请求可能包含具有独占字段(例如 title_en 和 title_es)的相同 ID.如果有一种查询 id 列表是否存在的方法,我可以拆分数据并执行单独的插入和更新命令......这将是一个可接受的替代方案,但是否已经有一个处理程序可以做到这一点?在这一点上,我想避免做任何内部例程.

I do up to 50 updates in one request and request may contain the same id with exclusive fields (title_en and title_es for example). If there was a way of querying whether or not a list of id's exist, I could split the data and perform separate insert and update commands... This would be an acceptable alternative but is there already a handler that does this? I would like to avoid doing any in house routines at this point.

谢谢.

推荐答案

使用 Solr 4.0 你可以做一个 所有这些文档的部分更新 仅更改已更改的字段将使整个文档保持不变.id 应该匹配.

With Solr 4.0 you can do a Partial update of all those document with just the fields that have changed will keeping the complete document same. The id should match.

这篇关于SOLR 可以执行 UPSERT 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆