Note that there are some explanatory texts on larger screens.

plurals
  1. POrails sunspot solr search by keywords
    primarykey
    data
    text
    <p>I am working around search for 2 days to query keyword search using <code>sunspot solr</code>. I am unable to understand</p> <p>My expected output is</p> <p>if i search for <code>laptops in US</code> it should search for laptop and us</p> <p>But the below code search only laptops and not the other words. How can i achieve it.</p> <p>My fulltext is working good</p> <p>I have edited <code>schema.xml</code></p> <pre><code>&lt;fieldType name="text" class="solr.TextField" omitNorms="false"&gt; &lt;analyzer&gt; &lt;tokenizer class="solr.StandardTokenizerFactory"/&gt; &lt;filter class="solr.StandardFilterFactory"/&gt; &lt;filter class="solr.LowerCaseFilterFactory"/&gt; &lt;filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="15"/&gt; &lt;/analyzer&gt; &lt;analyzer type="query"&gt; &lt;tokenizer class="solr.StandardTokenizerFactory"/&gt; &lt;filter class="solr.StandardFilterFactory"/&gt; &lt;filter class="solr.LowerCaseFilterFactory"/&gt; &lt;/analyzer&gt; &lt;/fieldType&gt; </code></pre> <p>MY model contains</p> <pre><code>searchable do text :title,:description,stored: true time :updated_at text :product do product.name if product end text :product_model do product_model.name if product_model end end </code></pre> <p>My controller is</p> <pre><code>@search = Post.search do fulltext params[:search] do query_phrase_slop 1 end end </code></pre> <p><strong>Edit 1</strong></p> <p>I have two row with <code>pizza</code> in one column and <code>post</code> in other column. If i search for <code>pizza</code> it returns 5 result if i search for <code>post</code> it returns 1 result. And finally if i search for <code>pizza post</code> it results none. But expected output is to get 6 result.</p> <p>I changed <code>fulltext params[:search] do</code> to <code>keywords params[:search] do</code></p> <p><strong>Edit 2</strong></p> <pre><code>def index @search = Post.search do fulltext params[:search].split(' ') do phrase_slop 1 end end @posts = @search.results end </code></pre>
    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.
 

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