文字列を検索する
SOSL 検索を実行するには、Search リソースを使用します。単純な文字列を検索するには、HTTP GET メソッドを使用します。より視覚的な階層で、JSON ファイルを使用して複雑な文字列を検索するには、HTTP POST メソッドを使用します。
GET メソッドを使用した SOSL 検索の例
次の例では、{test} の SOSL 検索を実行します。この例の検索文字列は URL 符号化されている必要があります。
- 使用例
-
1curl https://na1.salesforce.com/services/data/v20.0/search/?q=FIND+%7Btest%7D -H "Authorization: Bearer token" - リクエストボディの例
- 不要
- レスポンスボディの例
-
1[ 2 { 3 "attributes" : 4 { 5 "type" : "Account", 6 "url" : "/services/data/v20.0/sobjects/Account/001D000000IqhSLIAZ" 7 }, 8 "Id" : "001D000000IqhSLIAZ" 9 }, 10 { 11 "attributes" : 12 { 13 "type" : "Account", 14 "url" : "/services/data/v20.0/sobjects/Account/001D000000IomazIAB" 15 }, 16 "Id" : "001D000000IomazIAB" 17 } 18]
GET メソッドを使用した単純な検索の例 (ベータ)
次の例では、{test} の検索を実行します。この例の検索文字列は URL 符号化されている必要があります。
- 使用例
-
1curl https://na1.salesforce.com/services/data/v20.0/search/?qs=test -H "Authorization: Bearer token" - リクエストボディの例
- 不要
- レスポンスボディの例
-
1[ 2 { 3 "attributes" : 4 { 5 "type" : "Account", 6 "url" : "/services/data/v20.0/sobjects/Account/001D000000IqhSLIAZ" 7 }, 8 "Id" : "001D000000IqhSLIAZ" 9 }, 10 { 11 "attributes" : 12 { 13 "type" : "Account", 14 "url" : "/services/data/v20.0/sobjects/Account/001D000000IomazIAB" 15 }, 16 "Id" : "001D000000IomazIAB" 17 } 18]
POST メソッドを使用した検索の例 (ベータ)
使用可能なすべての検索機能にアクセスする POST メソッドを使用して検索を実行します。
- 使用例
-
1curl https://na1.salesforce.com/services/data/v35.0/search "Authorization: Bearer token-H "Content-Type: application/json” -d “@search.json” - リクエストボディの例
- 不要
- JSON ファイルの例
-
1{ 2“qs”:”foo”, 3“fields” : [“id”, “firstName”, “lastName”], 4“sobjects”:[{”fields”:[”id”, “name”], 5 “name”: “Account”, 6 “where”: “DISTANCE(My_Location_Field__c,GEOLOCATION(37,122),'mi') < 100”, 7 } 8 } 9 “orderBy”: {“fields”: “name” 10 “order”: “ASC”, 11 “WhereAreNulls”: “last” 12 }, 13 “limit”:20 14 }, 15 16 {“name”: “Contact”} 17 ], 18"in":"ALL", 19"overallLimit":100, 20“defaultLimit”:10 21“offset”:5, 22"updateViewStat": true, 23"updateTracking": true, 24“dataCategory”: 25{"groupName":"GlobalCategory__c","operator":"below","categories":["NorthAmerica__c"]} , 26 {"groupName":"GlobalCategory__c","operator":"above","categories":["SanFrancisco__c"]} ] 27 28} - レスポンスボディの例
-
1[ 2 { 3 "attributes" : 4 { 5 "type" : "Account", 6 "url" : "/services/data/v20.0/sobjects/Account/001D000000IqhSLIAZ" 7 }, 8 "Id" : "001D000000IqhSLIAZ" 9 }, 10 { 11 "attributes" : 12 { 13 "type" : "Account", 14 "url" : "/services/data/v20.0/sobjects/Account/001D000000IomazIAB" 15 }, 16 "Id" : "001D000000IomazIAB" 17 } 18]