I'm using a relational DB for items, and i开发者_Python百科ndex them with Solr for getting the fast full-text search that Solr provides. But in the same time, I need the user to be able to filter by item status, that is of course a value particular to this user.
An ItemUserStatus value is an association between: an item, a user and a status, so it's a different table. So I need to use the searching capabilities of Solr, but need in the same query to filter by user specific information that does not seem indexable to me.
An example query would sound like: get me the items with title "Title" that you have set in the "Pending" state. I'm not sure what is the best way to do this, or if I'm using the right tools.
Thanks, Stefan
When designing your Solr schema, you need to denormalize/flatten your data. In this case, it seems that you're searching for "items", so the schema would revolve around items. When populating your Solr index, you'd have a field "Title" and another dynamic field "State", so your query would be as simple as Title:something State_123:Pending
where 123 is the user id.
Take a look at RavenDB. It is a document-oriented database built on top of Lucene, so you get a hybrid of Solr and a database, with the exception it is not meant to be a search engine, but rather a full featured doc-database with full-text search support on text fields.
A Linq expression to query RavenDB for your example would then be:
from doc in docs
where doc.Title == "Title" && doc.State == DocState.Pending
select doc
精彩评论