Solr和MySQL,如何保持更新的索引,和,是一个DB甚至需要如果它的简单? [英] Solr and MySQL, How to keep an updated index, and, is a DB even needed if it's simple?

查看:163
本文介绍了Solr和MySQL,如何保持更新的索引,和,是一个DB甚至需要如果它的简单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个完全的初学者与Solr,所以忍受我。 :)



在我当前的项目中,我有一个非常简单的DB - 只有1个表,包含4个字段:id,name,subject,msg。
$ b

我理解的方式,每次添加(或删除)一个新记录时,我需要将该记录添加到索引,基本上执行两个操作:将记录插入到DB中,



这是标准程序,还是有一种方法可以指示Solr自动重新索引数据库表,有时间间隔或有更新?



此外,由于表格如此简单,将此信息存储在DB中是否有意义?为什么不保留在Solr索引中,考虑到我想要的记录可以通过名称,主题和msg来搜索?



我的设置是Java,Hibernate,MySQL ,和Solrj。

解决方案

使用数据库或者没有真正归结为你想要保存和增长这些数据的长期。破坏整个Solr索引(并丢失所有数据)比破坏整个数据库容易得多,容易得多。此外,Solr没有很大的支持来修改模式,而不是从一个新的索引开始。例如,您可以添加其他字段很好,但是您不能在不擦除您的索引的情况下更改字段的名称或类型。



如果您使用DB,则可以使用 DataImportHandler 将Solr设置为直接从数据库索引。对于你的模式,这应该是很直接,但是这可能会很痛苦,因为你的数据库更复杂。我认为使用已经设置的Hibernate对象有一些优势,只需使用Solrj插入它们。 DataImportHandler的另一个痛点是它完全由http控制。因此,您需要使用 wget curl 来管理单独的cron作业(或其他一些代码) / p>

I'm a complete beginner with Solr, so bear with me. :)

In my current project I have a very simple DB - just 1 table that contains 4 fields: id, name, subject, msg.

The way I understand, every time a new record is added (or removed), I'd need to add that record to the index, essentially performing two operations: inserting the record into the DB and adding it to the index.

Is this standard procedure, or is there a way to direct Solr to automatically reindex the DB table either at some interval or whenever there are updates?

Also, since the table is so simple, does it even make sense to store this info in the DB? Why not just keep it in the Solr index, considering that I want the records to be searchable by name, subject, and msg?

My setup is Java, Hibernate, MySQL, and Solrj.

解决方案

Using a database or not really boils down to how long term you want to keep and grow this data. It is much, much easier to corrupt a whole Solr index (and lose all of your data) than it is to corrupt a whole database. Also, Solr does not have great support for modifying a schema without starting with a fresh index. For instance, you could add another field just fine, but you could not change the name or type of a field without wiping out your index.

If you do go with a DB, you can setup Solr to index directly from the DB using DataImportHandler. For your schema, this should be pretty straightforward, but this can get painful quickly as your DB gets more complex. I think there is some advantage to using the Hibernate objects you already have setup and just inserting them using Solrj. The other pain point with DataImportHandler is that it is completely controlled using http. So you need to manage separate cron jobs (or some other code) to handle the scheduling using wget or curl.

这篇关于Solr和MySQL,如何保持更新的索引,和,是一个DB甚至需要如果它的简单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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