articles = Article.search do |s|
s.fulltext "Java Script"
end
How do i tell sunspot like give me all the results which exactly matches "Java Script" Right now am getting results like "Java, Unix Scripting" (I think its the edge n gram which i am using for stemming takes this scripting results)
I found a couple of questions in stack overflow . unfortunately, no body answered the way i want. Hence i am posting this question here. I request the moderators not to mark it as duplicate
Here is what you can add to your controller to make "Quoted Values" return an exact match.
@search = Program.search do
fulltext params[:search].gsub( '"', '"\\' ) unless params[:search].blank?
//...
end
If you had text like this that is being searched...
the fox jumped over the tree
Search for fox over would return 1 row.
However a search for "fox over" (in quotes) would return 0 rows.
Search for "fox jumped" (also in quotes) would return 1 rows. This is the exact match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With