I'm building a system where I use Solr for search over my content, and MySQL to store the content. The rationale is that MySQL is a good persistent storage solution, and I can join data with other tables and have more versatile queries. On the other hand, I'm looking for very high performance in my reads.
Would it be better to use Solr to both search and store the data, and 开发者_JAVA技巧retrieve the data items directly from Solr, rather than getting an index from Solr and then performing a Select on MySQL?
I would still technically need to goto MySQL to grab related data, but perhaps I could store that in Solr as well.
More to the point - is Solr a reasonable data storage solution in this context? (Would still store in MySQL for persistence in either case).
It depends on what you need from the results.
You can certainly store documents in Solr with extra fields, and I believe you can declare some fields as part of the document, but not part of the index. Depending on what you need from a search result, you may be able to get all you need frm the extra fields to satisfy the search. If that is the case, you can skip the secondary lookup to MySQL.
Also consider how current you need the data to be. Is it sufficient to fetch data from the Solr index, given that it may not be in sync with the latest changes from MySQL? Or do you need to fetch from MySQL to ensure you have the latest data?
精彩评论