Ruby on rails 我们如何搜索任何单词都可以在sunspot solr on rails项目中搜索

Ruby on rails 我们如何搜索任何单词都可以在sunspot solr on rails项目中搜索,ruby-on-rails,solr,ruby-on-rails-3.2,sunspot-solr,Ruby On Rails,Solr,Ruby On Rails 3.2,Sunspot Solr,我如何用句子搜索全文和搜索任何匹配的单词 例:- “我可以找到”正在模型ttle中搜索 它必须显示与“may”、“i”、“find”匹配的结果 我得到的输出只是搜索键也接受单词数组,所以我们可以通过下面的代码简单地得到它 def custom_search test = Model.search do fulltext key do fields(:title) query_phrase_slop 1 end without(:field_disabled, true) fac

我如何用句子搜索全文和搜索任何匹配的单词

例:-

“我可以找到”正在模型ttle中搜索

它必须显示与“may”、“i”、“find”匹配的结果


我得到的输出只是搜索键也接受单词数组,所以我们可以通过下面的代码简单地得到它

def custom_search
test = Model.search do 
 fulltext key do
  fields(:title)
  query_phrase_slop 1
 end
 without(:field_disabled, true)
 facet(:obj_type)
end
if test.hits.size==0 #check the condition for no result matched for full text and passing every word
test = Model.search do 
 fulltext key.split(' ') do # key.split(' ') code make total sentence into array of words
  fields(:title)
  query_phrase_slop 1
 end
 without(:field_disabled, true)
 facet(:obj_type)
end
end
return test
end

我得到的输出只是搜索键也接受单词数组,所以我们可以通过下面的代码简单地得到它

def custom_search
test = Model.search do 
 fulltext key do
  fields(:title)
  query_phrase_slop 1
 end
 without(:field_disabled, true)
 facet(:obj_type)
end
if test.hits.size==0 #check the condition for no result matched for full text and passing every word
test = Model.search do 
 fulltext key.split(' ') do # key.split(' ') code make total sentence into array of words
  fields(:title)
  query_phrase_slop 1
 end
 without(:field_disabled, true)
 facet(:obj_type)
end
end
return test
end

@Subbarao我工作了两天,但我找不到解决方法是的,我已经完成了将句子拆分成多个单词的工作。拆分(“”)@Subbarao我工作了两天,但我找不到解决方法是的,我已经完成了将句子拆分成多个单词的工作。拆分(“”)