MetaDataQuery.SetQueryString
----------------------------

Sets the predicate to search.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [MetaDataQuery](component_MetaDataQuery.md) | [8.0](newinversion80.md) | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |

MBS( "MetaDataQuery.SetQueryString"; Query; QueryString ) 

**MBS**( **"MetaDataQuery.SetQueryString";** /\* Sets the predicate to search. \*/  
**$Query**; /\* The reference number of the query. \*/   
**$QueryString**) /\* The query string.e.g. "kMDItemContentType=\\"com.apple.application-bundle\\"" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Query | The reference number of the query. | $query |
| QueryString | The query string. | "kMDItemContentType=\\"com.apple.application-bundle\\"" |

### Result

Returns OK or error.

### Description

Sets the predicate to search.  
The plugin will build the predicate with the given query string.  
Setting this property while a query is running stops the query and discards the current results. The receiver immediately starts a new query.  
  
See list of metadata keys here:  
[https://developer.apple.com/documentation/coreservices/file\_metadata/mditem/common\_metadata\_attribute\_keys](https://developer.apple.com/documentation/coreservices/file_metadata/mditem/common_metadata_attribute_keys)  
  
Expression syntax:  
[https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html#//apple\_ref/doc/uid/TP40001849-CJBEJBHH](https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html#//apple_ref/doc/uid/TP40001849-CJBEJBHH)  
### Examples

Search for applications

 MBS ( "MetaDataQuery.SetQueryString"; $Query ; "kMDItemContentType=\\"com.apple.application-bundle\\"")  
Start a query:

 Set Variable \[ $query ; Value: MBS ( "[MetaDataQuery.Create](MetaDataQueryCreate.md)" ) \]   
Set Variable \[ $r ; Value: MBS ( "MetaDataQuery.SetQueryString"; $Query ; "kMDItemContentType=\\"com.apple.application-bundle\\"") \]   
Set Variable \[ $r ; Value: MBS ( "[MetaDataQuery.StartQuery](MetaDataQueryStartQuery.md)"; $Query ) \]  
Search with wildcard with LIKE:

 MBS ( "MetaDataQuery.SetQueryString"; $Query ; "kMDItemFSName like\[c\] '\*3625.jpg' ")  
### See also

- [MetaDataQuery.Create](MetaDataQueryCreate.md)
- [MetaDataQuery.QueryString](MetaDataQueryQueryString.md)
- [MetaDataQuery.StartQuery](MetaDataQueryStartQuery.md)

### Example Databases

- [Mac only/MetaDataQuery/Find FileMaker Databases](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/MetaDataQuery/Find%20FileMaker%20Databases.shtml#1ScriptAnchor_)
- [Mac only/MetaDataQuery/Search Applications](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/MetaDataQuery/Search%20Applications.shtml#1ScriptAnchor_)

### Blog Entries

- [Spotlight search in FileMaker with MBS Plugin](https://www.mbsplugins.de/archive/2017-12-16/Spotlight_search_in_FileMaker_/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 16th December 2017 , last changed 8th September 2021

  
[MetaDataQuery.SetEvaluate](MetaDataQuerySetEvaluate.md) - [MetaDataQuery.SetScript](MetaDataQuerySetScript.md)

[HTML Version](MetaDataQuerySetQueryString.shtml)