Note that there are some explanatory texts on larger screens.

plurals
  1. PONested searching in SunSpot Solr
    primarykey
    data
    text
    <p>I am trying to implement a Solr based search for a message thread. Each message can have many replies(The replies can be ONLY one level deep.). I want to retrieve the parent messages with content matching the search key OR replies matching the search key.</p> <p>E.g:</p> <pre><code>Hello Jack Hello Janice How are you? .. I am Janice How are you? Welcome to the Jungle Nothing better to do. </code></pre> <p>Searching for <code>Janice</code> should return the following resultset:</p> <pre><code>Hello Jack # one of the child messages matches the key word I am Janice # parent message matched the keyword) </code></pre> <p>My model is as follows:</p> <pre><code>class Message &lt; ActiveRecord::Base belongs_to :parent, :class_name =&gt; "Message" has_many :replies, :class_name =&gt; "Message", :foreign_key =&gt; :parent_id # content searchable do text :content integer :parent_id end end </code></pre> <p>What is the DSL syntax for specifying nested subquery like conditions?</p> <p><strong>Edit 1</strong></p> <p>I considered creating a compound text index field for holding all the indexes. But this approach is not viable in my scenario as I have to ensure that replies match certain additional criteria.</p> <pre><code>class Message &lt; ActiveRecord::Base belongs_to :parent, :class_name =&gt; "Message" has_many :replies, :class_name =&gt; "Message", :foreign_key =&gt; :parent_id belongs_to :category # content searchable do text :content integer :category_id integer :parent_id end end </code></pre> <p>In the above model, I want to restrict the text search to a given category.</p>
    singulars
    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