Try the simplest, cleanest design first (at least on paper), before you start resorting to either dynamic fields or multi-valued fields or other messy approaches. Like, one collection for stories, which would have a story id and a second collection for comments, each with a comment id and a field that is the associated story id and user id. And a third collection for users and their profiles. Identify the user and get their user id. Identify the story (maybe by keyword search) to get story id. Then identify and facet user comments by story id and user id and whatever other search criteria, and then facet on that.

-- Jack Krupansky

-----Original Message----- From: samabhiK
Sent: Monday, May 13, 2013 5:24 AM
To: solr-user@lucene.apache.org
Subject: Best way to design a "story and comments" schema.

Hi, I wish to know how to best design a schema to store comments in stories /
articles posted.
I have a set of fields:
  /   <field name="subject" type="text_general"
indexed="true" stored="true"/>
  <field name="keywords" type="text_general"
indexed="true" stored="true"/>
  <field name="category" type="text_general"
indexed="true" stored="true"/>
  <field name="content" type="text_general"
indexed="false" stored="true" />   /
Users can post their comments on a post and I should be able to retrieve
these comments and show it along side the original post. I only need to show
the last 3 comments and show a facet of the remaining comments which user
can click and see the rest of the comments ( something like facebook does ).
One alternative, I could think of, was adding a dynamic field for all
comments :
/<dynamicField name="comment_*"  type="string"
indexed="false"  stored="true"/>/
So, to store each comments, I would send a text to solr of the form ->
For Field Name: /comment_n/ Value:/[Commenter Name]:[Commenter ID]:[Actual
Comment Text]/
And to keep the count of those comments, I could use another field like so
:/<field name="comment_count" type="int"
indexed="true" stored="true"/>/
With this approach, I will have to do some calculation when a comment is
deleted by the user but I still can manage to show the comments right.
My idea is to find the best solution for this scenario which will be fast
and also be simple.
Kindly suggest.



--
View this message in context: http://lucene.472066.n3.nabble.com/Best-way-to-design-a-story-and-comments-schema-tp4062867.html Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to