Search files by text


This API allows you to search a given text in the file metadata. Since filename is also metadata for the file object, filename search should also use this mode. The 'location' in the fragments object gives the character index (zero based) of the match in the searched string.

Endpoint URL: {network.internalDNSName or network.proxyURL} received in DeviceInformation

Request Syntax

GET /v2/filesSearch/text


Request Headers

ParameterDescriptionRequired
Accept-EncodingRequest using the Accept-Encoding header, with a value of gzip to compress response data. This reduces network traffic and improves response time.

Value of type: string
false
AuthorizationAn access token with nas_read_only or nas_read_write scope as well as the File Permission with value ReadFile or FileOwner for the file or a parent.

Value of type: string
true
If-MatchA previous response ETag or *. Returns the object only if its entity tag (ETag) is the same as the one specified.

Value of type: string
false
If-None-MatchA previous response ETag or *. Returns the object only if its entity tag (ETag) is different from the one specified.

Value of type: string
false


Request Query Parameters

ParameterDescriptionRequired
fieldsThe fields to return.

Value of type: csv

Default: All fields
false
limitThe page size limit.

Value of type: integer

Default: 20
false
pageTokenThe pageToken obtained from the last response.

Value of type: string
false
prettyWhether to pretty print the response. It refers to the process of displaying source code or other items in a presentable way.

Value of type: boolean

Default: false
false
qSearch keywords optionally surrounded by double quotes to indicate a search phrase.

Value of type: string
true
rankTimeoutMaximum time (in ms.) allowed to order the results by rank.

Value of type: integer
false


200 Response

OK

Response Headers

ParameterDescriptionRequired
Content-TypeIndicates the media type for the message body. Specify application/json as the content-type.false
EtagAn eTag (entity tag) is an HTTP response header used to determine the change in file metadata and content.false


Response Payload

ParameterDescriptionRequired
matchesThe matches

Value of type: array
true
matches.fileThe matched file

Value of type: object
false
matches.fragmentsThe matched fragments

Value of type: object
false
matches.fragments.locationsThe fragment locations.

Value of type: array
false
matches.fragments.locations.indexStarting character index (zero based) of the match in the fragment text.

Value of type: integer
false
matches.fragments.locations.lengthLength of the match in the fragment text.

Value of type: integer
false
matches.fragments.textThe matched fragment text. Will be arbitrarly truncated from it's source data.

Value of type: string
false
pageTokenThe pageToken for the next request.

Value of type: string
false


Example

Sample request to search files by text called 'hello.' Two files having metadata name 'hello.txt', "helloworld.txt" and "world hello.txt" are returned.

Request

GET /sdk/v2/filesSearch/text?q=hello HTTP/1.1Host: Endpoint-URLAuthorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJ

Response

{"pageToken": "","matches": [  {      "file": {          "id": "CnMytqM8qkRcBjNdB3WCVWk_x2OwqiMEjvjUVrUf",          "parentID": "sThX0Q3v6ByO9hkm7h5ItBrF7brWeeimnfRD8py0",          "eTag": "\"CA\"",          "size": 344,          "mimeType": "text/plain; charset=utf-8",          "name": "hello.txt",          "mTime": "2018-03-23T23:06:59Z",          "cTime": "2018-03-23T23:07:50.142Z",          "extension": ".txt",          "hidden": "none",          "mimeTypes": [              "text/plain; charset=utf-8"          ],          "trashed": false,          "family": false      },      "fragments": [          {              "text": "hello.txt",              "locations": [                  {                      "index": 0,                      "length": 5                  }              ]          }      ]  },  {      "file": {          "id": "bwYzM-TXiw6UbX4bigmr8n3xSRVMEUkD6qFhp76h",          "parentID": "LgN1O_RHzSPuYvyEEIffnqaB3pQ_7EwijNDhTnuS",          "eTag": "\"CA\"",          "size": 344,          "mimeType": "text/plain; charset=utf-8",          "name": "helloworld.txt",          "mTime": "2018-03-23T23:07:17Z",          "cTime": "2018-03-23T23:08:02.491Z",          "extension": ".txt",          "hidden": "none",          "mimeTypes": [              "text/plain; charset=utf-8"          ],          "trashed": false,          "family": false      },      "fragments": [          {              "text": "helloworld.txt",              "locations": [                  {                      "index": 0,                      "length": 10                  }              ]          }      ]  },  {      "file": {          "id": "w1nxFSegq5EhuUp5fyUaKfhCIEOpUYuNOOc1SpLN",          "parentID": "GN9VWPPEjTm0UJl53fDxkWMZxOBzAY9ohbbUS0E0",          "eTag": "\"Cg\"",          "size": 344,          "mimeType": "text/plain; charset=utf-8",          "name": "world hello.txt",          "mTime": "2018-03-23T23:15:00.922Z",          "cTime": "2018-03-23T23:15:00.922Z",          "extension": ".txt",          "hidden": "none",          "mimeTypes": [              "text/plain; charset=utf-8"          ],          "trashed": false,          "family": false      },      "fragments": [          {              "text": "world hello.txt",              "locations": [                  {                      "index": 6,                      "length": 5                  }              ]          }      ]  }  ]  }