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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -