使用Solr搜索索引作为数据库 - 是这个“错误”? [英] Using Solr search index as a database - is this "wrong"?

查看:184
本文介绍了使用Solr搜索索引作为数据库 - 是这个“错误”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的小组正在与使用Solr作为搜索索引的第三方CMS进行合作。我注意到,似乎作者正在使用Solr作为数据库的排序,每个文档返回包含两个字段:

My team is working with a third party CMS that uses Solr as a search index. I've noticed that it seems like the authors are using Solr as a database of sorts in that each document returned contains two fields:


  1. Solr文档ID(基本上是类名和数据库ID)

  2. 整个对象的XML表示

因此,基本上它运行针对Solr的搜索,下载对象的XML表示,然后从XML实例化对象,而不是使用id在数据库中查找它。

So basically it runs a search against Solr, download the XML representation of the object, and then instantiate the object from the XML rather than looking it up in the database using the id.

我的肠道感觉告诉我这是一个坏的做法。 Solr是一个搜索索引,而不是一个数据库...所以我更有意义的是执行我们对Solr的复杂搜索,获取文档ids,然后从数据库中拉出相应的行。

My gut feeling tells me this is a bad practice. Solr is a search index, not a database... so it makes more sense to me to execute our complex searches against Solr, get the document ids, and then pull the corresponding rows out of the database.

当前的实现是否完美,或者是否有数据支持重构已经成熟的想法?

Is the current implementation perfectly sound, or is there data to support the idea that this is ripe for refactoring?

当我说XML表示 - 我的意思是一个存储字段,包含所有对象的属性,而不是多个存储字段的XML字符串。

When I say "XML representation" - I mean one stored field that contains an XML string of all of the object's properties, not multiple stored fields.

推荐答案

根据 应用程序,使用Solr作为数据库是完全合理的。事实上,这几乎是 guardian.co.uk正在做

It's perfectly reasonable to use Solr as a database, depending on your application. In fact, that's pretty much what guardian.co.uk is doing.

这是绝对不是不好的做法本身。

It's definitely not bad practice per se. It's only bad if you use it the wrong way, just like any other tool at any level, even GOTOs.

当你说An XML representation ...的时候,我会发现这是一个错误的方式,就像任何其他工具,假设你正在谈论有多个存储的Solr字段,并使用Solr的XML格式检索这些字段,而不仅仅是一个大的XML内容字段(这将是对Solr的一个可怕的使用)。 Solr使用XML作为默认响应格式这一事实在很大程度上无关紧要,您也可以使用二进制协议 ,因此在这方面与传统的关系数据库非常相似。

When you say "An XML representation..." I assume you're talking about having multiple stored Solr fields and retrieving this using Solr's XML format, and not just one big XML-content field (which would be a terrible use of Solr). The fact that Solr uses XML as default response format is largely irrelevant, you can also use a binary protocol, so it's quite comparable to traditional relational databases in that regard.

最终,这取决于您的应用程序的需求。 Solr 主要是文字搜寻引擎,但也可作为许多应用程式的NoSQL资料库。

Ultimately, it's up to your application's needs. Solr is primarily a text search engine, but can also act as a NoSQL database for many applications.

这篇关于使用Solr搜索索引作为数据库 - 是这个“错误”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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