首页 \ 问答 \ Solr:通过查询部分更新删除值(Solr: remove value with partial update by query)

Solr:通过查询部分更新删除值(Solr: remove value with partial update by query)

我想从大索引中的多值字段中删除一个特定值,我需要先查询哪些文档包含该值,即:

  1. 检索包含特定值的文档的ID。
  2. 部分更新这些文件(使用remove )。

Solr版本是5.1。 如有必要,我可以更新,但更改日志并不表示与此问题有任何关联。

我通过Solr Web界面( http:// localhost:8983 / solr /#/ core / documents )在/select端点上尝试了以下查询(在一些变体中),尝试从所有文档中删除值:

{"id":"*", "field": {"remove":"value"} }

服务器响应“成功”,但没有更新文档。

我可以做的是查询field:value ,提取文档ID,并(以编程方式)为这些ID生成更新查询,类似于本答案中指出的内容。 但我希望应该有一个更直接的解决方案。

部分更新文档和其他相关网页中提供的示例在此处并不真正适用,因为它们假定已事先知道更新文档的ID。 关于类似问题的大多数其他讨论在引入部分更新之前(在Solr 4中)引用旧的Solr版本。


I want to remove one specific value from a multivalued field in a large index, where I need to query first which documents contain that value, i.e.:

  1. retrieve IDs of the documents containing the specific value.
  2. partially update these documents (using remove).

Solr version is 5.1. I could update if necessary, but the change logs do not indicate any relevance to this issue.

I've tried the following query (in a few variations) on the /select endpoint through the Solr web interface (http://localhost:8983/solr/#/core/documents), trying to remove the value from all the documents:

{"id":"*", "field": {"remove":"value"} }

The server response is "success", but no document is updated.

What I could do is to query for field:value, extract the document IDs, and (programmatically) generate update queries for these IDs, similar to what has been indicated in this answer. But I would expect that there should be a more straight-forward solution.

The examples presented in the partial updates documentation and other related web pages are not really applicable here because they assume that the ID of the updated documents are known in advance. Most other discussions about similar issues refer to old Solr versions, before partial updates were introduced (in Solr 4).


原文:https://stackoverflow.com/questions/39407091
更新时间:2022-07-17 19:07

最满意答案

  1. Minerals将始终注入Granite ,无论您选择哪种注射技术,但有些注射比其他注射更“清洁” - 例如,选项1使您无法控制注射的完成方式,选项3意味着您的课程可以'是不可改变的。
  2. 如果未绑定Minerals ,缺少公共无参数构造函数,并且缺少@Inject构造函数,则Guice会抛出异常,除非您使用@Inject(optional = true)

  1. Minerals will always be injected into the Granite, whichever injection technique you choose, but some injections are "cleaner" than others -- for example, option 1 gives you less control over how the injection is done, and option 3 means your class can't be immutable.
  2. If Minerals isn't bound, lacks a public no-argument constructor, and lacks an @Inject constructor, then Guice throws an exception, unless you use @Inject(optional = true).

相关问答

更多
  • 我认为首选的Guice模式是这样的: public class HolderPatter { static class Bar { @Inject Bar(BarDependency dependency) {} } static class Baz { @Inject Baz(BazDependency dependency) {} } static class BarHolder { @Inject(optional=true) Bar value = n ...
  • 您是否尝试在每个构造函数中注入Provider而不是实际实例? 如果你不需要构造函数代码中的其他实例,那么只需将Provider存储到final字段,稍后再使用该字段(通过调用get() )。 Did you try injecting a Provider in each constructor instead of the actual instances? If you don't need the other instance in the code of constructor, th ...
  • 我找到的解决方案(如果不是最好的)是定义一个CustomServletContext并使用guice-bridge工件,在jersey问题跟踪器中引用问题HK2-121之后。 解决方案: public class KratosServletContainer extends ServletContainer { private Injector injector; @Inject KratosServletContainer(Injector injector, Resou ...
  • 乍一看,你似乎错过了Db注释依赖和StatsdClient的绑定。 你需要像这样提供缺少的绑定到你的模块 bind(Db.class).annotatedWith(SystemDb.class).to(DbImplOfSomeSort.class); bind(StatsdClient.class).to(StatsdClientImplOfSomeSort.class); Guice能够使用公共无参数构造函数或具有@Inject的构造函数自动注入具体类,而无需在模块中定义任何特定的绑定,但涉及到接口时, ...
  • 你是对的,这种注射只能通过使用工厂来解决。 如果你有Foo(A a, B b)注入A并且B在运行时传递,你将需要一个Factory FooFactory.createFoo(B b) ,它在内部保存对A的引用。 幸运的是,Guice有@Assisted Injection的概念。 您必须提供工厂的界面,但可以将实现的“魔力”留给Guice。 它有很好的文档记录: https : //github.com/google/guice/wiki/AssistedInject 您需要额外依赖com.google.i ...
  • Minerals将始终注入Granite ,无论您选择哪种注射技术,但有些注射比其他注射更“清洁” - 例如,选项1使您无法控制注射的完成方式,选项3意味着您的课程可以'是不可改变的。 如果未绑定Minerals ,缺少公共无参数构造函数,并且缺少@Inject构造函数,则Guice会抛出异常,除非您使用@Inject(optional = true) 。 Minerals will always be injected into the Granite, whichever injection techn ...
  • 看起来“辅助注射”可能是一个解决方案: http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/assistedinject/FactoryModuleBuilder.html 如果您无权访问Foo的构造函数,则它不起作用。 编辑:我发现我可以通过扩展类型并将它们添加到我想要使用的构造函数中来添加辅助注入注释: public class AssistedFoo extends Foo { @Assis ...
  • 您的标题和问题不符。 标题的答案显然是肯定的 - 你还可以注入什么,以及Guice可以创建什么样的实例,如果不是具体的类? 你的问题的答案是你可以通过阻止编译B来防止A注入B,如果它使用A - 通过限制可见性(如public , private ),或者通过构造你的构建以便A不在编译B时的类路径 Your title and question don't match. The answer to the title is yes, obviously - what else can you inject i ...
  • 如果要使用完全相同的配置实例(类Props),可以将其实例绑定为具有提供程序绑定的单例 。 这当然不是唯一的解决方案,但对我来说这是有道理的。 这是一个例子: 定义提供者: public class PropsProvider implements Provider { @Override public Props get() { ...read and return Props here... } } 在单例范围内使用提供程序绑定: bind ...
  • 看看Binder doc: http://google-guice.googlecode.com/git/javadoc/com/google/inject/Binder.html requireExplicitBindings()可能就是你所需要的。 通过使用模块中的语句,禁用自动绑定,仅注入通过bind()或provides类配置的类。 Apparently, the only way to do this is to write a provider method for each prohibite ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)