Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Problem with agent query and set (Read 2104 times)
Barbara Snyder
Full Member
*
Offline



Posts: 80

Problem with agent query and set
Apr 14th, 2015, 8:55pm
 
Hi --

I have a user attribute "category" that is a set. I have an agent query:

  $category.icontains("someTerm");

that doesn't work. There are definitely some notes that should match.

  $Name.icontains("someWord") does work as expected.

I also tried

  $category.icontains("someTerm")==true;

because TbRef indicates a boolean return value, but still no luck

How do I make this agent work?

Thanks -- Barbara
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Problem with agent query and set
Reply #1 - Apr 14th, 2015, 9:37pm
 
Testing lists/sets, the contains operator, syntax AttributeName.contains("pattern"), returns true if a list/set contains an exact match for the the designated pattern; the test is case sensitive regardless of agent query case sensitivity settings; regex matches are not supported. See more.

Bottom line you can't (without kludgy workarounds**) do a partial match for s list or set individual value. You can at best to an exact match for the whole list item value. Slightly counter-intuitively you use list.contains("somevalue") or list.icontains("somevalue") as opposed to list == "somevalue".

** if you really want to: see here.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Problem with agent query and set
Reply #2 - Apr 15th, 2015, 11:30am
 
Barbara Synder: I'm not quite sure I follow you.  I just did the following experiment.

  • $MySet is a set attribute.  In Note A, I make it a key attribute and assign it the value frogs;dogs.
  • I make an agent with the query $MySet.icontains("frogs").
  • The new agent does indeed gather A.



Back to top
 
 
WWW   IP Logged
Barbara Snyder
Full Member
*
Offline



Posts: 80

Re: Problem with agent query and set
Reply #3 - Apr 15th, 2015, 1:34pm
 
I was looking for a partial match, eg frog not frogs.

Sent from a small keyboard using big thumbs
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Problem with agent query and set
Reply #4 - Apr 16th, 2015, 2:55pm
 
contains() and contains(), when applied to sets and lists, only match complete elements.

If you really do need to search for partial elements, coerce the list or set to a string and use the string version of .contains()
Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Problem with agent query and set
Reply #5 - Apr 19th, 2015, 3:25am
 
For details on doing the latter in MB's post, see the last link in my previous post.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print