This may be useful:
http://sphinxsearch.com/docs/current.html#conf-index-field-lengths

You should be able to use this by adding `set_property :index_field_lengths => 
true` to your index definition, and then, once you’ve run rake ts:rebuild, 
there’s an attribute with the same name as your field which is the length of 
the field.

However, this can’t be used if you’ve also got :sortable on any fields. For 
that scenario, you’d need to create this attribute manually, but you don’t need 
to have a column for it - it can be generated on the fly. An example presuming 
the column for the field in question is ‘name’:

  has “LENGTH(name)”, :as => :name_length, :type => :integer

And then you can use name_length as an attribute.

— 
Pat

On 16 May 2014, at 7:47 am, Travis J I Corcoran <[email protected]> wrote:

> Is there any way to build a ranking expression that references the string 
> length of the text field?  e.g. if I'm searching for "Fred", I'd like to rank 
> a record that has a full text of "Fred" over one that has a full text of 
> "there are several words in this document including the word Fred".
> 
> I've been staring at the Sphinx docs 
> http://sphinxsearch.com/docs/current.html#document-factors and I don't see 
> anything.  If not, I might have to add a column to my records in SQL, then 
> tweak the before_save callback in ActiveRecord to update that, then use that 
> field in the :ranker expression...
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.

Reply via email to