How to fuzzy match a ruby on rails elasticsearch. -


i have controller action allows me search document via document guid. issue guids 20+ characters. able search document using first 5 characters of guid.

what have is:

search_params = { sort: { sent_at: :desc } }  if can_search && params[:document_id].present?     search_params[:filter] = { term: { "_id" => params[:document_id] } }     @documents = elasticsearch::model.search(search_params, [document]) else     @documents = elasticsearch::model.search(search_params, [document]).page(params[:page]).per(20) end 

this works fine if enter exact guid. partial matching doesn't work.

you can using wildcardquery that

search_params[:filter] = { wildcard: { "_id" => "*#{params[:document_id]}*" } }     

Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -