Search files by text

Contents

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

Parameter Description Required
Accept-Encoding Request 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
Authorization An 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-Match A 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-Match A 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

Parameter Description Required
fields The fields to return.

Value of type: csv

Default: All fields
false
limit The page size limit.

Value of type: integer

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

Value of type: string
false
pretty Whether 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
q Search keywords optionally surrounded by double quotes to indicate a search phrase.

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

Value of type: integer
false


200 Response

OK

Response Headers

Parameter Description Required
Content-Type Indicates the media type for the message body. Specify application/json as the content-type. false
Etag An eTag (entity tag) is an HTTP response header used to determine the change in file metadata and content. false


Response Payload

Parameter Description Required
matches The matches

Value of type: array
true
matches.file The matched file

Value of type: object
false
matches.fragments The matched fragments

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

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

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

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

Value of type: string
false
pageToken The 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.1
Host: Endpoint-URL
Authorization: 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
                  }
              ]
          }
      ]
  }
  ]
  }

Have question about this section?