esp wrote:
> > esp wrote:
> > > 1) Is there any way to add static data into a  model.   For example if
> > > a
> > > table with a row that has a name field that is "Loch Ness" is there a
> > > way
> > > that I can add static text to this so it will return results for the
> > > keyword "lake".
> >
> > You can pass raw SQL fragments to TS in your define_index block.
> > Assuming you're using mysql:
> >
> >   indexes "IF(`name` = 'Loch Ness', 'lake','')", :as => :landmark
> >
> Not sure I follow the synax - I'm using PostgreSQL.

An indexes call can just be a string that contains a raw SQL statement.
Pretend you're adding a manual field to an SQL SELECT.

The comments in lib/thinking_sphinx/index/builder.rb have (some) further
information on this feature.

The IF() function is for MySQL, but I'm sure PostgreSQL will have
something equivalent.

-- James Healy <jimmy-at-deefa-dot-com>  Mon, 27 Apr 2009 21:55:08 +1000

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to