I need thinking_sphinx query to retrieve “begins_with” values.
means if I give Student.search ‘a’, I want to display all student who have name starts with a.
I have indexed the name field already.Now, to retrieve a student, I have to give the exact name.
I need thinking_sphinx query to retrieve begins_with values. means if I give Student.search ‘a’,
Share
Sounds like you want wildcard searches. Either add this to your
config/sphinx.ymlfile – or create it if you don’t already have one:Or you can put it in a specific index – as infix/prefix settings increase the size of your indices dramatically:
And then, run
rake ts:rebuildso the changes are known by Sphinx and processed in the indices, and then you can search like this:And if you use min_infix_len instead of min_prefix_len, you can match within words as well – that is, put the star on either side:
Finally – if you always want your queries to have wildcard stars on each end of every term, use
:star => truein your searches:Hope this helps you get the result you’re looking for 🙂