I am using ruby, Sequel and postgres. I have implemented full text search as follows:
get '/full_text_search' do
search_term = params[:search_term]
result = DB[:candidates].full_text_search(:experience, search_term).map do |row|
{ :id => row[:id], :first => row[:first], :last => row[:last], :designation => row[:designation], :company => row[:company], :email => row[:email], :phone => row[:phone], :city => row[:city], :country => row[:country], :industry => row[:industry], :status => row[:status], :remarks => row[:remarks], :experience => row[:experience] }
end
halt 200, result.to_json
end
This is executed by passing a search term from a text box, via an ajax call, so:
$(document).ready(function(){
$("#full_text_search").click(function(){
var search_term = $("#search_box").val();
$.getJSON("/full_text_search?search_term="+search_term, function(data) {
$.each( data, function( key, value ) {
//do something with returned data here
});//end each
});//end getJSON
});//end click
});//end doc
If my search term is just one word, "private" for example, I get the results back no problem but if I try a search term of 2 words (or more) "private equity", for example, I get an error and no data is returned.
So my question is how can I execute full text search (as above) with a phrase of 2 or more words?
I have already tried encapsulating the passed parameter with '' and "" unsuccessfully.
All help gratefully received. Thank you.