0
votes

I have a 'users' MySQL table. Users' names are stored in a separate 'names' table.

The index file looks like:

ThinkingSphinx::Index.define :user, :with => :active_record do

  indexes names.text, :as => :name

end

The search works fine most the times, but some entries are just not in the results. Mr. "Thomas J Jefferson", for example, isn't returned when searching for "Thomas", or "J", or "Jefferson", or "Thomas J Jefferson". All his fellow presidents have a better treatment from the engine.

I just have no idea about what could be wrong.

Rails: 3.2.18, ruby: 1.9.3, ThinkingSphinx: 3.1.1

1
Are you sure you've got your versions right? TS v1.4 is for Rails 2.3, and your index definition style was only introduced in TS v3… that said, are you re-indexing the data once you've added these new names to users? - pat
TS version was wrong, edited. Yes, I re-indexed the data. - Miotsu
From the information provided, it all looks correct. Is the name connected to a user? Are you running User.search 'Thomas J Jefferson', or something more complex than that? - pat
The call to the search method is: User.search('Thomas J Jefferson', match_mode: :extended, per_page: 1000, retry_stale: true, populate: true) - Miotsu
And the Name in question is attached to a user? (Unrelated, but :match_mode is not required - TS v3 uses the SphinxQL protocol, which only uses the extended matching style - thus, you'll still get the matching you want, and the setting is ignored). - pat

1 Answers

-1
votes

You are searching the full text which will start with Thomas.

So to search the given result you have to write below code in thinking_sphinx.yml file

min_infix_len: 1 enable_star: 2

In search query write: User.search("@name '#{params[:name]}'") you will get your result.