0
votes

I'm using Thinking Sphinx in a Rails application combined with the jQuery autocomplete plugin for my search form. I'm searching on an Entry model with a "note" attribute (text data type). I'm using the following to return the excerpt:

<%= entry.excerpts.note %>

The "Excerpt Settings" section of the documentation states that "At this point in time, Thinking Sphinx does not have the ability to customise the excerpts settings..." and that Sphinx uses a maximum length of 256 characters.

However, I would like to display around only 100 or so characters in my search results. I tried Rails' truncate method, but sometimes the matching term occurs after the 100th character (and is therefore not visible to the user).

Has anyone found a way to get TS to render shorter excerpts?

1

1 Answers

1
votes

Not yet documented, but try setting :excerpt_options as part of your search parameters (they'll get passed along to the excerpt call):

Entry.search 'foo', :excerpt_options => {:limit => 100}