简体   繁体   English

我应该使用哪种方法? 用SOLR索引MySQL数据库

[英]Which method should I go with; Indexing MySQL db with SOLR

I have a classifieds website, with approx 30 categories of classifieds. 我有一个分类广告网站,大约有30个分类广告类别。

I am on the stage where I have to build MySQL tables and index them with SOLR. 我处于必须构建MySQL表并使用SOLR对其进行索引的阶段。 Each row in a table has around 15 fields... 表格中的每一行都有大约15个字段...

I am looking for performance! 我正在寻找表现!

I wonder which of these two methods works best: 我想知道这两种方法中哪一种最有效:

1- Have one MySQL table for each category, meaning 30 tables , and then have multiple indexes in SOLR ( This would mean that if the user only wants to search in one specific category, then that table/index is searched, thus gaining performance (I think). However, if the user searches ALL categories at once, then all tables/indexes would have to be searched. ) 1-每个类别有一个MySQL表, 即30个表 ,然后在SOLR中具有多个索引(这意味着如果用户只想在一个特定类别中进行搜索,则将搜索该表/索引,从而获得性能(我认为)。但是,如果用户一次搜索所有类别,则必须搜索所有表/索引。)

2- Have one and only one MySQL table, and only one index in SOLR. 2-在SOLR中只有一个MySQL表,只有一个索引。

Thanks 谢谢

Assuming that all of the different types of classifieds have the same structure, I would do the following: 假设所有不同类型的分类具有相同的结构,我将执行以下操作:

Store the text in a single table, along with another field for category (and other fields for whatever other information is associated with a category). 将文本与类别的另一个字段(以及与类别关联的其他信息的其他字段)一起存储在单个表中。

In Solr, build an index that has a text field, a category field, and a PK field. 在Solr中,建立一个具有文本字段,类别字段和PK字段的索引。 The text and category fields would be indexed but not stored, and the PK field (storing the primary key corresponding to your MySQL table) would be stored but not indexed. text和category字段将被索引但不被存储,而PK字段(存储与您的MySQL表相对应的主键)将被存储但未被索引。

Allow the user to do two kinds of searches: one with just text, and one with text and category. 允许用户执行两种搜索:一种仅使用文本,另一种使用文本和类别。 For the latter, the category should be an exact match. 对于后者,类别应完全匹配。 The Solr search will return a list of PKs which will allow you to then retrieve documents from MySQL. Solr搜索将返回PK列表,使您可以从MySQL检索文档。

You will not see much of a performance improvement by splitting your index up into 30 indices, because Solr/Lucene is already very efficient at finding data via its inverted indices. 通过将索引分成30个索引,您不会看到很多性能改进,因为Solr / Lucene通过倒排索引查找数据已经非常有效。 Specifying the category name is sufficient. 指定类别名称就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM