手动指定如何建立索引?
我正在研究 Thinking Sphinx,因为它有可能解决索引问题。看起来它有一个非常特定的API来告诉它哪些字段模型上的索引。我不喜欢让这个抽象层妨碍我而又无法回避它。问题是我不相信 Sphinx 能够正确解释我的模型,因为该模型可能具有任何可以想象的属性。基本上,我想在 RDBMS 中对 JSON 进行编码。在某种程度上,我希望让 RDBMS 表现得像 MongoDB(RDBMS 具有我不想没有的功能)。如果可以让 TS 或其他索引来理解我的模型,这可能会起作用。是否可以手动向 TS 提供键/值对?
"person.name.first" => "John", "person.name.last" => "Doe", "person.age" => 32,
"person.address" => "123 Main St.", "person.kids" => ["Ed", "Harry"]
是否有其他索引工具可用于 Ruby 来索引 JSON?
(顺便说一下,我探索了各种各样的 NoSQL 数据库。我正在尝试解决一组非常具体的需求。)
I'm looking into Thinking Sphinx for it's potential to solve an indexing problem. It looks like it has a very specific API for telling it what fields to index on a model. I don't like having this layer of abstraction in my way without being able to sidestep it. The thing is I don't trust Sphinx to be able to interpret my model properly as this model could have any conceivable property. Basically, I want to encode JSON in a RDBMS. In a way, I'm looking to make an RDBMS behave like MongoDB (RDBMSes have features I don't want to do without). If TS or some other index could be made to understand my models this could work. Is it possible to manually provide key/value pairs to TS?
"person.name.first" => "John", "person.name.last" => "Doe", "person.age" => 32,
"person.address" => "123 Main St.", "person.kids" => ["Ed", "Harry"]
Is there another indexing tool that could be used from Ruby to index JSON?
(By the way, I have explored a wide variety of NoSQL databases. I am trying to address a very specific set of requirements.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Matchu 在评论中指出的那样,Sphinx 通常直接与数据库交互。这就是 Thinking Sphinx 如此构建的原因。
然而,Sphinx(但不是 Thinking Sphinx)也可以接受 XML 数据格式 - 所以如果您想走这条路,请随意。与使用普通关系数据库/ActiveRecord 和 Thinking Sphinx 方法相比,您必须更深入地了解底层 Sphinx 结构。 Riddle 可能对于构建解决方案很有用,但您仍然需要首先了解 Sphinx 本身。
As Matchu has pointed out in the comments, Sphinx usually interacts directly with the database. This is why Thinking Sphinx is built like it is.
However, Sphinx (but not Thinking Sphinx) can also accept XML data formats - so if you want to go down that path, feel free. You're going to have to understand the underlying Sphinx structure much more deeply than you would if using a normal relational database/ActiveRecord and Thinking Sphinx approach. Riddle may be useful for building a solution, but you'll still need to understand Sphinx itself first.
基本上,当您指定要索引的内容时(即,当您要构建自己的索引时),您正在使用 Map/Reduce 的 Map 部分。 CouchDB 正是支持这一点。我在使用 Couch 时遇到的唯一问题是,我想要查询其他文档对象作为 Map/Reduce 的基础,因为这些文档将包含有关我想要如何构建索引的元数据。然而,这违背了 Map/Reduce 的原则,因为您必须在没有外部数据的情况下单独映射文档。如果您需要外部数据,则会将其非规范化到您的文档中。
Basically, when you're specifying what you want to index--that is, when you want to build your own index--you're using the Map part of Map/Reduce. CouchDB supports exactly this. The only problem I ran into with Couch is that I want to query other document objects as the basis of my Map/Reduce since those documents would contain metadata about how I want to build my indexes. This goes against the grain of Map/Reduce however as you have to map a document in isolation with no external data. If you need external data it would instead be denormalized into your documents.