Searching with dm-sphinx-adapter

12 views
Skip to first unread message

Rolly

unread,
Feb 10, 2009, 3:45:09 PM2/10/09
to DataMapper
Hi,

I've been playing around with dm-sphinx-adapter and dm-is-searchable
and I was wondering if there's anyway to do full-text queries like:
Item.search('keywords', options_hash)

Instead of:
Item.search(attribute_keywords_hash, options_hash)

I guess the first one could just use the same keywords against every
searchable attribute, but combine them using OR rather than AND.

I've haven't figured whether this is possible yet, has anyone managed
something like this with dm-sphinx-adapter?

Shane Hanna

unread,
Feb 11, 2009, 7:36:31 AM2/11/09
to DataMapper
Hey I'm the author of dm-sphinx-adapter.

At the moment you can:

1) Full text search all fields in the index(es) without attribute
conditions using a raw query:
Item.search(:conditions => [%q{search for me}], default_options_hash)

2) Full text search one or more fields or attributes in the index(es)
with optional :default conditions:
Item.search(:field_blah => 'value', :attribute_blah => 'value',
default_options_hash)

See the query tests and DM::A::Sphinx::Query documentation for more
examples of whats possible.

I'd like to be able to express a search across all fields *and* supply
optional attribute conditions (which sounds like what you are asking
for) but I can't see a nice way hook extra logic in before DM's query
construction and validation which happens in shared code in
Model#scoped_query.

I hope the syntax talk that's been going on will allow non DOAs more
flexibility perhaps by passing query conditions through an adapter
hook for query construction? In the meantime I'm open to suggestions,
patches and will freely hand out commit privileges if you can't
possibly wait for me to merge your pull requests :)

Cheers,
Shane.

Rolly

unread,
Feb 12, 2009, 3:35:23 PM2/12/09
to DataMapper
Thanks Shane, that helps alot, and thanks for contributing the
adapter. It's making Sphinx integration a breeze :-)

I'm right in the middle of doing search integration for an app now so
hopefully I'll find a way to contribute something back.


Cheers,
Rolly
Reply all
Reply to author
Forward
0 new messages