I should add - right now the RC[‘q’] works if its a single word however if its a multiple word string it returns no results. What I want to do is break-up the q search term on spaces and append them to the “OR” in restrictions. How can this be done?
There are two ways that I’ve been able to get it to work in my code.
The first way is better, by far, and uses disjunction():
`
c = newCriteria();
// create a dynamic array of search terms…this example isn’t dynamic, but you get the idea
var TheOrArray =[
c.restrictions.iLike( ‘keywords’, ‘%’ & event.getValue( ‘q’, ‘’ ) & ‘%’ ),
c.restrictions.iLike( ‘keywords’, ‘%’ & event.getValue( ‘q’, ‘’ ) & ‘%’ ),
…more here if you need them
];
c.disjunction( TheOrArray );
`
The second is really ugly, but works.
If you look at the source for or(), it simply takes N arguments. So, you could create a structure to pass as argumentsCollection to or():
`
c = newCriteria();
//build or() structure…easy to make this dynamic…
var TheOR={
“foo” = c.restrictions.ilike(‘keywords’,’%’ & event.getValue(‘q’,’’) & ‘%’),
“bar” = c.restrictions.ilike(‘keywords’,’%’ & event.getValue(‘q’,’’) & ‘%’),
…
};
c.or( argumentCollection=TheOr );
`
There may be other ways to do it, but this worked for me.