API Reference / API Methods / MultiClusters / Search userID
Required API Key: Admin
Method signature
$client->searchUserIds(string query)

$client->searchUserIds(string query,[
  // All the following parameters are optional
  'clusterName' => string clusterName,
  'page' => integer page,
  'hitsPerPage' => integer hitsPerPage,
])

About this method

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.

We released a new version of the Java API client in public beta. Read the beta documentation for more information.

You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

Search for userIDs.

The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds propagate to the different clusters.

To keep updates moving quickly, the index of userIDs isn’t built synchronously with the mapping. Instead, the index is built once every 12h, at the same time as the update of userID usage. For example, when you perform a modification like adding or moving a userID, the search will report an outdated value until the next rebuild of the mapping, which takes place every 12h.

Examples

Read the Algolia CLI documentation for more information.

Search userID

1
2
3
4
5
6
7
8
9
$page = 0;
$hitsPerPage = 12;

$client->searchUserIds('query', [
  // All the following parameters are optional
  'clusterName' => 'c1-test',
  'page' => $page,
  'hitsPerPage' => $hitsPerPage,
]);

Parameters

query
type: string
Required

Query to search. The search is a prefix search with typoTolerance. Use empty query to retrieve all users.

clusterName
type: string
default: null
Optional

If specified only clusters assigned to this cluster can be returned.

page
type: integer
default: 0
Optional

Page to fetch.

hitsPerPage
type: integer
default: 20
Optional

Number of users to return by page.

Response

This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here. You can view the response in the logs (using the getLogs method).

JSON format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  "hits": [
    {
      "userID": "user9",
      "clusterName": "c11-test",
      "nbRecords": 3,
      "dataSize": 481,
      "objectID": "user9",
      "_highlightResult": {
        "userID": {
          "value": "<b>user<\/b>9",
          "matchLevel": "full",
          "fullyHighlighted": false,
          "matchedWords": [
            "user"
          ]
        },
        "clusterName": {
          "value": "c11-test",
          "matchLevel": "none",
          "matchedWords": []
        }
      }
    }
  ],
  "nbHits": 10,
  "page": 0,
  "hitsPerPage": 20,
  "updatedAt": 1514902377
}
hits
list of user object

List of user object matching the query.

nbHits
integer

Number of userIDs matching the query.

page
integer

Current page.

hitsPerPage
integer

Number of hits retrieved per page.

updatedAt
string

Timestamp of the last update of the index

hits âž” user object

userID
string

userID of the requested user

clusterName
string

Cluster on which the data of the user is stored.

nbRecords
integer

Number of records this user has on the cluster

dataSize
integer

Data size taken by this user on the cluster

objectID
string

userID of the requested user. Same as userID.

_highlightResult

hits âž” _highlightResult object

Highlighted attributes. Each attributes contains the following attributes:

value
string

Markup text with occurrences highlighted. The tags used for highlighting are specified via highlightPreTag and highlightPostTag.

matchLevel
string

Indicates how well the attribute matched the search query. Can be: none or partial or full. See search matchLevel for more details.

matchedWords
list

List of words from the query that matched the object.

fullyHighlighted
boolean

Whether the entire attribute value is highlighted.

Did you find this page helpful?