Platforms to show: All Mac Windows Linux Cross-Platform
Back to MDQueryMBS class.
MDQueryMBS.AttributeValueOfResultAtIndex(name as string, index as UInt32) as Variant
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.7 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
name: The attribute name for which to return the values. If the attribute is not one of those requested in the valueListAttrs or sortingAttrs parameters to one of the query creation functions, the result will be nil.
index: The index into the query's result list. If the index is negative, or is equal to or larger than the current number of results in the query, the behavior is undefined.
Returns he value of the attribute, or nil if the attribute doesn't exist in the query on that result.
MDQueryMBS.BatchingParameters as MDQueryBatchingParamsMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
property | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
(Read and Write computed property)
MDQueryMBS.Constructor(query as MDQueryMBS, queryString as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Only results matched by the given query can be matched by the query expression of this query.
query: The parent query of the new query.
queryString: The query expression string for this query. This expression in effect may further restrict the matches found by the parent query. If the string is empty the behavior is undefined.
valueListAttributes: An optional array of attribute names. The query will collect the values of these attributes into uniqued lists, which can be used or displayed to summarize the results of the query, or allow a user to further qualify the items for which they are searching. This parameter may be empty if no value lists are desired. Value list collection increases CPU usage and significantly increases the memory usage of an MDQuery. The attribute names are strings.
sortingAttributes: An optional array of attribute names. The query will results of the query based on the values of these attributes. The first name in the array is used as the primary sort key, the second as the secondary key, and so on. The comparison of like-typed values is a simple, literal comparison. This parameter may be empty if no sorting is desired. Sorting increases memory usage and significantly increases the CPU usage of an MDQuery. However, when possible, it is almost always cheaper to have the MDQuery do the sorting, rather than you fetching all the results and attributes from each of them and doing the sorting yourself. The attribute names are strings.
See also:
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string, sortingAttributes() as string)
- Constructor(queryString as string)
- Constructor(queryString as string, valueListAttributes() as string)
- Constructor(queryString as string, valueListAttributes() as string, sortingAttributes() as string)
MDQueryMBS.Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Only results matched by the given query can be matched by the query expression of this query.
query: The parent query of the new query.
queryString: The query expression string for this query. This expression in effect may further restrict the matches found by the parent query. If the string is empty the behavior is undefined.
valueListAttributes: An optional array of attribute names. The query will collect the values of these attributes into uniqued lists, which can be used or displayed to summarize the results of the query, or allow a user to further qualify the items for which they are searching. This parameter may be empty if no value lists are desired. Value list collection increases CPU usage and significantly increases the memory usage of an MDQuery. The attribute names are strings.
sortingAttributes: An optional array of attribute names. The query will results of the query based on the values of these attributes. The first name in the array is used as the primary sort key, the second as the secondary key, and so on. The comparison of like-typed values is a simple, literal comparison. This parameter may be empty if no sorting is desired. Sorting increases memory usage and significantly increases the CPU usage of an MDQuery. However, when possible, it is almost always cheaper to have the MDQuery do the sorting, rather than you fetching all the results and attributes from each of them and doing the sorting yourself. The attribute names are strings.
See also:
- Constructor(query as MDQueryMBS, queryString as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string, sortingAttributes() as string)
- Constructor(queryString as string)
- Constructor(queryString as string, valueListAttributes() as string)
- Constructor(queryString as string, valueListAttributes() as string, sortingAttributes() as string)
MDQueryMBS.Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string, sortingAttributes() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Only results matched by the given query can be matched by the query expression of this query.
query: The parent query of the new query.
queryString: The query expression string for this query. This expression in effect may further restrict the matches found by the parent query. If the string is empty the behavior is undefined.
valueListAttributes: An optional array of attribute names. The query will collect the values of these attributes into uniqued lists, which can be used or displayed to summarize the results of the query, or allow a user to further qualify the items for which they are searching. This parameter may be empty if no value lists are desired. Value list collection increases CPU usage and significantly increases the memory usage of an MDQuery. The attribute names are strings.
sortingAttributes: An optional array of attribute names. The query will results of the query based on the values of these attributes. The first name in the array is used as the primary sort key, the second as the secondary key, and so on. The comparison of like-typed values is a simple, literal comparison. This parameter may be empty if no sorting is desired. Sorting increases memory usage and significantly increases the CPU usage of an MDQuery. However, when possible, it is almost always cheaper to have the MDQuery do the sorting, rather than you fetching all the results and attributes from each of them and doing the sorting yourself. The attribute names are strings.
See also:
- Constructor(query as MDQueryMBS, queryString as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string)
- Constructor(queryString as string)
- Constructor(queryString as string, valueListAttributes() as string)
- Constructor(queryString as string, valueListAttributes() as string, sortingAttributes() as string)
MDQueryMBS.Constructor(queryString as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
queryString: The query expression string for this query. The syntax for query expressions is explained above in the header overview documentation.
valueListAttributes: An optional array of attribute names. The query will collect the values of these attributes into uniqued lists, which can be used or displayed to summarize the results of the query, or allow a user to further qualify the items for which they are searching. This parameter may be empty if no value lists are desired. Value list collection increases CPU usage and significantly increases the memory usage of an MDQuery. The attribute names are string.
sortingAttributes: An optional array of attribute names. The query will results of the query based on the values of these attributes. The first name in the array is used as the primary sort key, the second as the secondary key, and so on. The comparison of like-typed values is a simple, literal comparison. This parameter may be empty if no sorting is desired. Sorting increases memory usage and significantly increases the CPU usage of an MDQuery. However, when possible, it is almost always cheaper to have the MDQuery do the sorting, rather than you fetching all the results and attributes from each of them and doing the sorting yourself. The attribute names are strings.
The handle value is zero on failure.
See also:
- Constructor(query as MDQueryMBS, queryString as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string, sortingAttributes() as string)
- Constructor(queryString as string, valueListAttributes() as string)
- Constructor(queryString as string, valueListAttributes() as string, sortingAttributes() as string)
MDQueryMBS.Constructor(queryString as string, valueListAttributes() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
queryString: The query expression string for this query. The syntax for query expressions is explained above in the header overview documentation.
valueListAttributes: An optional array of attribute names. The query will collect the values of these attributes into uniqued lists, which can be used or displayed to summarize the results of the query, or allow a user to further qualify the items for which they are searching. This parameter may be empty if no value lists are desired. Value list collection increases CPU usage and significantly increases the memory usage of an MDQuery. The attribute names are string.
sortingAttributes: An optional array of attribute names. The query will results of the query based on the values of these attributes. The first name in the array is used as the primary sort key, the second as the secondary key, and so on. The comparison of like-typed values is a simple, literal comparison. This parameter may be empty if no sorting is desired. Sorting increases memory usage and significantly increases the CPU usage of an MDQuery. However, when possible, it is almost always cheaper to have the MDQuery do the sorting, rather than you fetching all the results and attributes from each of them and doing the sorting yourself. The attribute names are strings.
The handle value is zero on failure.
See also:
- Constructor(query as MDQueryMBS, queryString as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string, sortingAttributes() as string)
- Constructor(queryString as string)
- Constructor(queryString as string, valueListAttributes() as string, sortingAttributes() as string)
MDQueryMBS.Constructor(queryString as string, valueListAttributes() as string, sortingAttributes() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
queryString: The query expression string for this query. The syntax for query expressions is explained above in the header overview documentation.
valueListAttributes: An optional array of attribute names. The query will collect the values of these attributes into uniqued lists, which can be used or displayed to summarize the results of the query, or allow a user to further qualify the items for which they are searching. This parameter may be empty if no value lists are desired. Value list collection increases CPU usage and significantly increases the memory usage of an MDQuery. The attribute names are string.
sortingAttributes: An optional array of attribute names. The query will results of the query based on the values of these attributes. The first name in the array is used as the primary sort key, the second as the secondary key, and so on. The comparison of like-typed values is a simple, literal comparison. This parameter may be empty if no sorting is desired. Sorting increases memory usage and significantly increases the CPU usage of an MDQuery. However, when possible, it is almost always cheaper to have the MDQuery do the sorting, rather than you fetching all the results and attributes from each of them and doing the sorting yourself. The attribute names are strings.
The handle value is zero on failure.
See also:
- Constructor(query as MDQueryMBS, queryString as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string)
- Constructor(query as MDQueryMBS, queryString as string, valueListAttributes() as string, sortingAttributes() as string)
- Constructor(queryString as string)
- Constructor(queryString as string, valueListAttributes() as string)
MDQueryMBS.CountOfResultsWithAttributeValue(name as string, Value as Variant) as UInt32
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.7 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
name: The attribute name for which to return the number of results with the given value. If the attribute is not one of those requested in the valueListAttrs parameter to one of the query creation functions, the behavior is undefined.
value: The attribute value for which to return the number of results with that value. This parameter may be nil, in which case the number of results that do not contain the named attribute is returned.
Returns the number of results with that attribute and value.
Some examples using this method:
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
This should be called before iterating through the list of results to prevent the result list from changing during the iteration. The disabled state is a counter, and disabling can be done recursively and from different threads.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
This should be called when finished iterating through the list of results, to allow changes to the result list to occur. Changes will be allowed when all the disables have been matched by a corresponding enable.
MDQueryMBS.Execute(flags as Integer) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Queries only gather results or process updates while the current thread's run loop is running. Queries normally operate asynchronously, and send out progress and update notifications to report changes to the list of results that has been collected. Queries have two phases: the initial gathering of all currently matching results, and a second live-update phase where queries monitor the state of the system and update themselves to external changes in files or the operating environment (for example, as time advances, files which did not match the query when it was started may later match the query). Query notifications are posted within the context of the same thread which executes the query. [
here are three operational modes: (1) synchronous static queries, which collect the list of current results and then do not watch for updates to the results, (2) asynchronous static queries, which collect the results asychronously after this function returns, and then do not watch for updates to the results, and (3) asynchronous live queries which collect the initial results asychronously after this function returns, and then do watch for updates to the results, until the query is destroyed. There is little reason not to allow the fourth case, synchronous collection of initial results, followed by asynchronous monitoring for updates, so this may change in the future.
Flags: Options for the query.
Returns true if the query was started (executed in the case of a synchronous query), false otherwise. Queries cannot be executed more than once.
MDQueryMBS.GetSortOptionFlagsForAttribute(fieldName as string) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
fieldName: The attribute name for which sort option flags are to be fetched.
Returns an integer with flags. Currently can be 0 or 1.
Available on Mac OS X 10.7 or later.
MDQueryMBS.IndexOfResult(it as MDItemMBS) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Note that the index of a result will change over time, as the query's result list is updated.
Returns the index of the given result, or -1 if the value is not one of the query's existing results.
MDQueryMBS.IsGatheringComplete as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
A boolean indicating whether or not the first phase of a query has completed.
MDQueryMBS.QueryString as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
MDQueryMBS.ResultAtIndex(index as Integer) as MDItemMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
This function causes the result object to be created if it hasn't been created already. For performance reasons, it is not advisable to ask for results that you don't need, to avoid the cost of creating them. If possible, call this function to fetch only the results you need to display or otherwise process. Note that the index of a particular result will change over time, as the query's result list is updated.
index: The index into the query's result list.
If the index is negative, or is equal to or larger than the current number of results in the query, the behavior is undefined.
Returns the MDItem currently at the given index, or if a result-create function has been set, returns the result returned by that function.
MDQueryMBS.ResultCount as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Note that the number of results in a query will change over time as the query's result list is updated.
MDQueryMBS.Results(limit as Integer = -1) as MDItemMBS()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 13.5 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Internally does what ResultAtIndex does for up to limit entries.
Limit with -1 will cause no limit.
If possible, call this function to fetch only the results you need to display or otherwise process.
MDQueryMBS.SetMaxCount(size as Integer)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
This must be called before the query is executed.
size: The maximum number of results desired.
Some examples using this method:
MDQueryMBS.SetSearchScope(paths() as folderitem, options() as string)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
This may be used to limit searching to particular volumes. Tilde paths, or environment variables are not expanded. Calling this multiple times will replace the previous options. This must be called before the query is executed.
paths: An array of directories where you want to search. This array can be empty.
options: An array of scope options. Pass the kMDQueryScope* constants. This array can be empty.
Some examples using this method:
MDQueryMBS.SetSortOptionFlagsForAttribute(fieldName as string, flags as UInt32) as Boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
fieldName: The attribute name for which sort option flags are to be set.
The attribute name must have been part of the sortingFlags when the query was created.
flags: An integer containing MDQuerySortOptionFlags to be applied to the attibute
Returns a boolean, true on success, false on failure.
Available on Mac OS X 10.7 or later.
MDQueryMBS.SetSortOrder(sortingAttrs() as string) as Boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
sortingAttrs An array of attribute names, as in MDQueryCreate.
The query's result set will be sorted according to the order of these attributes. All names in the array have to have been passed as sortingAttrs when the query was created. The attribute names are strings.
Returns a boolean, true on success, false on failure.
Available on Mac OS X 10.7 or later.
MDQueryMBS.SortingAttributes as string()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Queries may be executed only once, so a stopped query cannot be restarted. The query will also not generate any result updates. The query is static after this function returns. The query will do final processing of results that have come in but not yet been processed (because, say, the batching parameters hasn't triggered that yet). That may trigger a progress notification, so be aware of that if you are stopping a query from within your progress note handler; that is, during this function, a recursive progress and/or finished notification might occur, which might recursively call your notification handler. It is safe to call this function recursively. You would call this function to stop a query that is generating way too many results to be useful, but still want to access the results that have come in so far. If a query is stopped before the gathering phase finishes, it will not report itself as finished, nor will it send out a finished notification.
MDQueryMBS.ValueListAttributes as string()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
MDQueryMBS.ValuesOfAttribute(name as string) as Variant()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Spotlight | MBS MacOSX Plugin | 9.7 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
The list is not ordered in any way. The list contains only one occurrence of each value. Note that this list may change over time, as the query's result list is updated.
name: The attribute name for which to return the values. If the attribute is not one of those requested in the valueListAttrs parameter to one of the query creation functions, the behavior is undefined.
Returns an array holding the value objects for that attribute.
Some examples using this method:
The items on this page are in the following plugins: MBS MacOSX Plugin.