11 Replies Latest reply on Feb 15, 2017 6:03 PM by skwan


    Rhys Kirk

      Numerous questions...answers if you know them please, no guess work...




      The above documentation states the following in the comments, which is incorrect, just saying:


      The same page states: "When a query is too complex for a server, then you will get a NotSupportedException."

      What defines a query that is too complex?


      On the Search Query Syntax page (https://techsupport.osisoft.com/Documentation/PI-AF-SDK/Html/33f7ca86-dbca-4aea-951a-1fd72f8fb468.htm) I want to specify the Primary Referenced Element of an AF Event Frame based on a Template.

      "ElementName" is supported by the AFEventFrameSearch but is that the Event Frame name (an Event Frame is an Element under the hood) or is that going to be the Primary Referenced Element name? I am too lazy busy to test extensively at this very moment in time.

        • Re: AFEventFrameSearch
          Rick Davin

          I'm checking on this for you, Rhys.

          • Re: AFEventFrameSearch
            David Hearn

            The sample examples have been rewritten for the next release and this error has already been fixed. Always good to have accurate examples.


            A query is too complex when using an older server and it cannot be converted to a search on the older server. For example if you specify a combination of 'Start' and 'End' filters that cannot be mapped to the equivalent AFSearchMode or AFEventFrameSearchMode then you will see this error.


            For an AFEventFrameSearch, you would use the 'Name' to search on the name of the event frame and 'ElementName' to search based upon the element names in the event frame's ReferencedElements collection.

            3 of 3 people found this helpful
            • Re: AFEventFrameSearch
              Roger Palmen

              On the second part, you will find an example of the query syntax here:Using the AFEventFrameSearch Class


              1. string query = string.Format("Element:{0} Template:{1}", Element.GetPath(Database), Template.GetPath(Database)); 
              3. var search = new AFEventFrameSearch(Database, "optional name", AFSearchMode.Overlapped, StartTime, EndTime, query); 
              5. IEnumerable<AFEventFrame> frames = search.FindEventFrames(startIndex: 0, fullLoad: false, pageST
              • Re: AFEventFrameSearch
                Rick Davin

                Hi Rhys,


                While you can filter on a referenced element, you really can't narrow precisely to the Primary Referenced Element.  Don't know how your database is arranged for most of mine, all my EF's have only 1 referenced element so luckily for me any referenced element IS the primary referenced element.  If your database is not the same way, then the best you may hope for is to have server-side filtering on the referenced element of interest, and then have a client-side check to additionally filter where PrimaryReferencedElement == referenced element of interest.


                Rhys Kirk said:

                I want to specify the Primary Referenced Element of an AF Event Frame based on a Template.


                Do you mean:

                1. I want to specify the referenced element of an [AF Event Frame based on a Template], or
                2. I want to specify the referenced element based on the element template of that referenced element?



                1 of 1 people found this helpful
                  • Re: AFEventFrameSearch
                    Rhys Kirk

                    Hi Rick...I mean no. 2. As in, I want all Event Frames where one or more of the Referenced Elements is using Template 'xyz'. Ideally, where the Template is any from a list of Templates I supply. I can do this manually easy enough but means fetching more EFs than I would like then checking client side (which I have working now).

                      • Re: AFEventFrameSearch

                        Hello Rhys,


                        Based on what is said in the Search Query Syntax documentation, looking at the Filters conditions (there is a table that shows to which AFObject the Search applies) I would try the filter

                        new AFSearchToken(AFSearchFilter.ElementReferenceTemplate,AFSearchOperator.Equal,  @"pathToYourElementTemplate")


                        In case you have not seen it yet, I'd recommend this post in case you need examples: Why you should use the new AF SDK Search


                        Searches are ANDed so you may need to run as many search queries as ElementTemplates you are looking for, but this should be more efficient than filtering client side I believe.


                        Hope this helps,

                        1 of 1 people found this helpful