more elaborate options include, building your own word index table, integrating with an external indexing engine. but looking at the full-text indexing options of the database itself is probably sufficient.
On Oct 14, 2:13 pm, Empty <[EMAIL PROTECTED]> wrote: > Also, don't forget the match operator is available on certain > backends: sqlite, sql server, oracle, mysql, and postgres. > > Michael > > On Tue, Oct 14, 2008 at 1:59 PM, <[EMAIL PROTECTED]> wrote: > > > this is somewhat frequent question, lookup the group in the past if > > anyone has something usable. > > > maybe something like > > query(cls).filter( > > or_(*[column == value for column in alternatives] )) > > if many values, use column.in_(values) instead of == > > > alternatives can come from yourtable.columns or > > classmapper( yourclas).iterate_properties. > > > things to check: > > - types, e.g. comparing strings and integers may fail or succeed > > - primary_key = set( c.key for c in class_mapper( cls).primary_key ) > > - relations/references maybe also be checked via .has/.any > > e.g. references = [ p for p in > > classmapper(yourclass).iterate_properties > > if (p not in primary_key > > and (not isinstance( p, PropertyLoader) #not a relation > > or p.use_list == False )) #or a singular reference > > ] > > these above are just for example, do your own filtering > > > ciao > > svil > > > On Tuesday 14 October 2008 20:26:16 Jorge Vargas wrote: > >> Hi, > > >> I'm trying to implement a "simple search" field in my application > >> and I was wondering which will be the best way to implement it on > >> SQLAlchemy. I have googled around and found several partial > >> solutions but none of them convince me of being the right way. > > >> My use case is the following. I got a textfield search box which > >> will post a set of words, my webapp is to take those words and do a > >> query in *any* field of the corresponding table, and it is to say > >> within just one table. For example I got a User class that has > >> first_name,last_name,address_fields. And I ran a query for "John > >> Thompson", that will bring me back a list of user objects where any > >> of the following is valid, "John" in first_name, "John" in > >> last_name, "John" in address, "Thompson" in first_name, "Thompson" > >> in last_name, "Thompson" in address_field. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---