简体   繁体   中英

How to search the pre and post part of the word using Thinking_sphinx gem on rails

I have created my search part successfully with the thinking_sphinx gem and I have searched a word it is showing correct, But the problem with the search is it need full word to be given to search exact match. I dont want to give exact word instead any particular character or part of words also be taken into account. help me to solve this problem..

example

say my word is "Sample"

instead of giving sample i need to specify part of the word like.

amp or ple

for rails code we will specify

find :all, :conditions => ["user_id like ? ", "%#{search}%"]

how to specify this, by using thinking_sphinx gem.

i tried with,

  User.search "*amp*"

but of no result guide me to solve this.

Got the Result,

At first I have added

development:
      enable_star: 1
      min_infix_len: 3

on config -> sphinx.yml

and I have rebuild my application by using

rake ts:rebuild

and then on controller,

User.search "*mple", :star => true

which result,

sample

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM