Searching for value based on partial string

Searching for an event frame based on Attribute Value is very useful. I am interested in knowing whether it can be used to search on String values, using only partial strings.

 

This article is quite useful:

https://pisquare.osisoft.com/s/Blog-Detail/a8r1I000000Gv9KQAS/coding-tips-for-using-the-afsearch-in-operator?t=1726547940087

 

But in it it explains that the "In" operator is used for searching for a string value that is in a list of pre-defined values. Does this mean that it can't use wildcard or other pattern matching?

 

I tried it in my own sample code, and it didn't work.

AFSearchValueToken textToken = new AFSearchValueToken("|TEXT_ATTRIBUTE", "*Hello*", AFSearchOperator.In);

I can always load all the AFEventFrames (eg. filter by template first), and then find the matching ones using Linq, but I was hoping for a server-side search.

 

  • Hi Andrew,

     

    I was the author of that referenced blog back when I was an OSIsoft employee. One restriction on IN that perhaps wasn't emphasized enough: IN only works with EXACT values, though for strings I think case-insensitive match is okay. So it cannot be used for partial strings or use wildcards.

     

    I would suggest your 2 areas of concern should be: (1) getting the right answer, and (2) getting that answer in a performant way.

     

    One issue with an AFAttributeSearch is that it does require a full load of all base elements into memory. Typically to review attribute values requires a sluggish client-side search.

    Note an event frame is a base element. The good news is that if your event frames are closed, i.e. have a EndTIme set, then with captured values you could possibly have the search occur server-side. But again, it is the partial strings that will cause performance issues.

     

     

  • Thanks. Yes - it is searching closed EventFrames. I think I will filter the list as much as possible server-side, then use Linq to do the text search client-side.

  • ​ 

     

    Would the "TEXT_ATTRIBUTE" example AFAttribute be a static AFAttribure or is it a PIPoint?

     

    Another consideration: is there any possible way to have some minor re-design. You have one AFAttribute string containing (or better yet) starting with given text. Can you split this into 2 AFAttributes: 1 for general categorization, and the 2nd for specific subcategory?

     

    Or consider using an Hierarchical AFEnumerationSet ?

    https://docs.aveva.com/bundle/pi-server-f-af-pse/page/1021919.html

     

    Example:

    100 = Hello

    110 = Hello|Admin

    120 = Hello|Manager

    130 = Hello|Engineer

    140 = Hello|Operator

     

    Now you could search on the numeric Value of the enumeration as being >= 100 and < 200.

  • I'm using event frames to allow Operators to capture comments, so the comments are very variable. They wanted a means of searching for text. I've been testing some approaches, and it can be quite slow (test database with 100,000 event frames). The performance issue is (unsurprisingly) in loading the attribute values, but I found that if I constrain the search, it is fast enough (1-4 seconds).

    Thanks for the Hierarchical Enumeration set info - didn't know about those, but they look really useful (for other purposes).