Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere / How to fit Solr into ASP.net MVC app (using nHibernate / Repository Pattern)
    primarykey
    data
    text
    <p>I'm currently in the middle of a reasonably large question / answer based application (kind of like stackoverflow / answerbag.com) We're using SQL (Azure) and nHibernate for data access and MVC for the UI app.</p> <p>So far, the schema is roughly along the lines of the stackoverflow db in the sense that we have a single <strong>Post</strong> table (contains both questions / answers)</p> <p>Probably going to use something along the lines of the following repository interface:</p> <pre><code>public interface IPostRepository { void PutPost(Post post); void PutPosts(IEnumerable&lt;Post&gt; posts); void ChangePostStatus(string postID, PostStatus status); void DeleteArtefact(string postId, string artefactKey); void AddArtefact(string postId, string artefactKey); void AddTag(string postId, string tagValue); void RemoveTag(string postId, string tagValue); void MarkPostAsAccepted(string id); void UnmarkPostAsAccepted(string id); IQueryable&lt;Post&gt; FindAll(); IQueryable&lt;Post&gt; FindPostsByStatus(PostStatus postStatus); IQueryable&lt;Post&gt; FindPostsByPostType(PostType postType); IQueryable&lt;Post&gt; FindPostsByStatusAndPostType(PostStatus postStatus, PostType postType); IQueryable&lt;Post&gt; FindPostsByNumberOfReplies(int numberOfReplies); IQueryable&lt;Post&gt; FindPostsByTag(string tag); } </code></pre> <p>My question is: Where / how would i fit solr into this for better querying of these "Posts" (I'll be using solrnet for the actual communication with Solr)</p> <p>Ideally, I'd be using the SQL db as merely a persistant store- The bulk of the above IQueryable operations would move into some kind of SolrFinder class (or something like that)</p> <p>The Body property is the one that causes the problems currently - it's fairly large, and slows down queries on sql.</p> <p>My main problem is, for example, if someone "updates" a post - adds a new tag, for example, then that whole post will need re-indexing. Obviously, doing this will require a query like this:</p> <blockquote> <p>"SELECT * FROM POST WHERE ID = xyz"</p> </blockquote> <p>This will of course, be very slow. Solrnet has an nHibernate facility- but i believe this will be the same result as above?</p> <p>I thought of a way around this, which I'd like your views on:</p> <ul> <li>Adding the ID to a queue (amazon sqs or something - i like the ease of use with this)</li> <li>Having a service (or bunch of services) somewhere that do the above mentioned query, construct the document, and re-add it to solr.</li> </ul> <p><strong>Another problem I'm having with my design:</strong> Where should the "re-indexing" method(s) be called from? The MVC controller? or should i have a "PostService" type class, that wraps the instance of IPostRepository?</p> <p>Any pointers are greatly received on this one!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload