Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFAttributeSearch Class

  • Last UpdatedNov 18, 2025
  • 11 minute read
AFAttributeSearch Class
This class is an implementation of the abstract AFSearch class the supports searching for AFAttribute objects.

Inheritance Hierarchy

SystemObject
  OSIsoft.AF.SearchAFSearch
    OSIsoft.AF.SearchAFSearchAFAttribute
      OSIsoft.AF.SearchAFAttributeSearch

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public sealed class AFAttributeSearch : AFSearch<AFAttribute>
Public NotInheritable Class AFAttributeSearch
	Inherits AFSearch(Of AFAttribute)

Dim instance As AFAttributeSearch
public ref class AFAttributeSearch sealed : public AFSearch<AFAttribute^>
[<SealedAttribute>]
type AFAttributeSearch =  
    class
        inherit AFSearch<AFAttribute>
    end

The AFAttributeSearch type exposes the following members.

Constructors

  NameDescription
Public method
AFAttributeSearch(AFDatabase, String, IListAFSearchToken) Obsolete.
Creates an instance of anAFAttributeSearch to search for AFAttribute objects that belong to either an AFElement or AFEventFrame using the specified list of search tokens.
Public method
AFAttributeSearch(AFDatabase, String, IListAFSearchTokenBase)
Creates an instance of anAFAttributeSearch to search for AFAttribute objects that belong to either an AFElement or AFEventFrame using the specified list of search tokens.
Public method
AFAttributeSearch(AFDatabase, String, String)
Creates an instance of anAFAttributeSearch to search for AFAttribute objects that belong to either an AFElement or AFEventFrame using the specified search query string.
Public method
AFAttributeSearch(AFDatabase, String, AFEventFrameSearchMode, AFTime, String)
Creates an instance of an AFAttributeSearch to search for AFAttribute objects using the specified AFEventFrameSearchMode, time and optional search query string.
Public method
AFAttributeSearch(AFDatabase, String, AFSearchMode, AFTime, AFTime, String)
Creates an instance of an AFAttributeSearch to search for AFAttribute objects using the specified AFSearchMode, times and optional search query string.

Properties

  NameDescription
Public property
CacheInterval
The search's cached automatic refresh interval.
(Inherited from AFSearch.)
Public property
CacheTimeout
The timeout to clean up the cached search in the server if it has not been used.
(Inherited from AFSearch.)
Public property
Database
The AFDatabase to be searched by the query.
(Inherited from AFSearch.)
Public property
Identity
This read-only property specifies the identity of the objects returned from the search.
(Inherited from AFSearch.)
Public property
PISystem
The PISystem to be searched by the query.
(Inherited from AFSearch.)
Public property
SearchName
The name of the search object.
(Inherited from AFSearch.)
Public property
ThrowOnError
Specifies it an exception will be thrown for missing objects or invalid data in the query.
(Inherited from AFSearch.)
Public property
TokenCollection
The tokens that represent this search object.
(Inherited from AFSearch.)
Public property
Tokens Obsolete.
The tokens that represent this search object.
(Inherited from AFSearch.)

Methods

  NameDescription
Public methodCode example
Aggregate
Performs all requested aggregates on the objects that match the search criteria.
(Inherited from AFSearch.)
Public methodCode example
AggregateAsync
Performs all requested aggregates on the objects that match the search criteria asynchronously.
(Inherited from AFSearch.)
Public methodCode example
BinnedSummaryTBin
Generates a summary broken down by the specified bins for items matching the search criteria.
(Inherited from AFSearch.)
Public methodCode example
BinnedSummaryAsyncTBin
Generates a summary broken down by the specified bins for items matching the search criteria asynchronously.
(Inherited from AFSearch.)
Public method
Close
Closes the search that is cached in the server.
(Inherited from AFSearch.)
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode example
FindAttributes Obsolete.
This method will return the AFAttribute objects that match the search tokens.
Public methodCode example
FindObjectFields(String, Int32, Int32)
This method will return the values as an IList for the specified fields for each of the objects that match the search tokens.
(Inherited from AFSearchT.)
Public methodCode example
FindObjectFieldsTObject(Int32, Int32)
This method will return the values for the fields defined by the user-defined type for each of the objects that match the search tokens.
(Inherited from AFSearchT.)
Public methodCode example
FindObjectFieldsTObject(String, FuncIListObject, TObject, Int32, Int32)
This method will return the values as an object for the specified fields for each of the objects that match the search tokens using the supplied factory delegate.
(Inherited from AFSearch.)
Public methodCode example
FindObjectFieldsTObject(String, FuncIListObject, TObject, Int32, Int32)
This method will return the values as an object for the specified fields for each of the objects that match the search tokens using the supplied factory delegate.
(Inherited from AFSearchT.)
Public methodCode example
FindObjectIds
This method will return a list of the ID for each object that matches the search tokens.
(Inherited from AFSearchT.)
Public methodCode example
FindObjects
This method will return the objects that match the search tokens.
(Inherited from AFSearchT.)
Public methodCode example
FrequencyDistribution
Generates a frequency distribution for the specified items.
(Inherited from AFSearch.)
Public methodCode example
FrequencyDistributionAsync
Generates a frequency distribution for the specified items asynchronously.
(Inherited from AFSearch.)
Public methodStatic member
GetFilters
Get the list of valid filters for a search query for the specified server.
Public method
GetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic member
GetObjectFields
Get the list of valid object fields that can used for the FindObjectFields(String, Int32, Int32) search for the specified server.
Public method
GetTotalCount
Returns the total count of the items that could be returned from the search query.
(Inherited from AFSearchT.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode example
GroupedSummary
Generates summaries broken down by group for items matching the search criteria.
(Inherited from AFSearch.)
Public methodCode example
GroupedSummaryAsync
Generates summaries broken down by group for items matching the search criteria asynchronously.
(Inherited from AFSearch.)
Public methodCode example
HistogramTBin
Generates a histogram using the specified weighting for items matching this search.
(Inherited from AFSearch.)
Public methodCode example
HistogramAsyncTBin
Generates a histogram using the specified weighting for items matching this search asynchronously.
(Inherited from AFSearch.)
Public methodCode example
IsMatch
Determines if the specified item matches the search query.
(Inherited from AFSearchT.)
Public method
Refresh
Refreshes the search that is cached in the server.
(Inherited from AFSearch.)
Public methodCode example
Summary(String, AFSummaryTypes)
Summarizes the result of this search.
(Inherited from AFSearch.)
Public method
Summary(String, AFSummaryTypes, String)
Summarizes the result of this search with the specified weighting.
(Inherited from AFSearch.)
Public methodCode example
SummaryAsync(String, AFSummaryTypes, CancellationToken)
Summarizes the result of this search asynchronously.
(Inherited from AFSearch.)
Public method
SummaryAsync(String, AFSummaryTypes, String, CancellationToken)
Summarizes the result of this search with the specified weighting asynchronously.
(Inherited from AFSearch.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFSearch.)
Public method
TryFindSearchToken Obsolete.
Find the AFSearchToken associated with the specified AFSearchFilter.
(Inherited from AFSearch.)
Public method
TryFindSearchTokens Obsolete.
Find the AFSearchToken list associated with the specified AFSearchFilter.
(Inherited from AFSearch.)

Remarks

This class provides support for query based searches for AFAttribute objects. The QuerySearchAttribute feature can be checked to determine if this query search is supported. A parent object type (Ex: Element, EventFrame) must be specified as part of the query.

A query string is parsed into search tokens which are used to specify the query filters for the search.

To optimize getting items from several pages of search results, a search can be cached by setting the CacheTimeout to a non-zero value. If you will only be getting items from the first page, then it is best to leave the cache disabled. The cache is disabled by default. Call the Refresh method to refresh the results of a cached search. Use the Close method to close a cached search when finished using it to free the memory used by the cached results in the server. Since the search implements the IDisposable interface, you can call the cached search in a using statement to automatically call the Close method when it leaves scope.

Note Notes to Callers
When a query is too complex for a server, then you will get a NotSupportedException.

Examples

 1// Get the Database
 2PISystems myPISystems = new PISystems();
 3PISystem myPISystem = myPISystems.DefaultPISystem;
 4if (myPISystem == null)
 5    throw new InvalidOperationException("Default PISystem was not found.");
 6AFDatabase myDB = myPISystem.Databases[dbName];
 7if (myDB == null)
 8    throw new InvalidOperationException("Database was not found.");
 9
10// Create a search to find the level of all TankElements.
11int count;
12using (var search = new AFAttributeSearch(myDB, "FindTankLevel", @"Element:{ Name:'TankElement*' } Name:'Level'"))
13{
14    search.CacheTimeout = TimeSpan.FromMinutes(10);
15
16    count = search.GetTotalCount();
17    Console.WriteLine("Found {0} Attributes.", count);
18    foreach (AFAttribute item in search.FindObjects())
19    {
20        Console.WriteLine("  Element {0} has {1} Attributes", item.Name, item.Attributes.Count);
21    }
22}
 1' Get the Database
 2Dim myPISystems As New PISystems()
 3Dim myPISystem As PISystem = myPISystems.DefaultPISystem
 4If myPISystem Is Nothing Then
 5    Throw New InvalidOperationException("Default PISystem was not found.")
 6End If
 7Dim myDB As AFDatabase = myPISystem.Databases(dbName)
 8If myDB Is Nothing Then
 9    Throw New InvalidOperationException("Database was not found.")
10End If
11
12' Create a search to find the level of all TankElements.
13Dim count As Integer
14Using search As New AFAttributeSearch(myDB, "FindTankLevel", "Element:{ Name:'TankElement*' } Name:'Level'")
15
16    search.CacheTimeout = TimeSpan.FromMinutes(10)
17
18    count = search.GetTotalCount()
19    Console.WriteLine("Found {0} Elements.", count)
20    For Each item As AFAttribute In search.FindObjects()
21        Console.WriteLine("  Element {0} has {1} Attributes", item.Name, item.Attributes.Count)
22    Next
23End Using

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5

See Also

TitleResults for “How to create a CRG?”Also Available in