This is documentation for v3 of the PHP API clients, which is not the latest version. To see the documentation for the latest version, see PHP v4.

This is documentation for v2 of the Ruby API clients, which is not the latest version. To see the documentation for the latest version, see Ruby v3.

This is documentation for v4 of the JavaScript API clients, which is not the latest version. To see the documentation for the latest version, see JavaScript v5.

This is documentation for v3 of the Python API clients, which is not the latest version. To see the documentation for the latest version, see Python v4.

This is documentation for v8 of the Swift API clients, which is not the latest version. To see the documentation for the latest version, see Swift v9.

This is documentation for v2 of the Kotlin API clients, which is not the latest version. To see the documentation for the latest version, see Kotlin v3.

This is documentation for v6 of the C# API clients, which is not the latest version. To see the documentation for the latest version, see C# v7.

This is documentation for v3 of the Java API clients, which is not the latest version. To see the documentation for the latest version, see Java v4.

This is documentation for v3 of the Go API clients, which is not the latest version. To see the documentation for the latest version, see Go v4.

This is documentation for v1 of the Scala API clients, which is not the latest version. To see the documentation for the latest version, see Scala v2.

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,
])

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.

About this method

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. Each API client encapsulates this response inside objects specific to the programming language, so that the actual response might be different. You can view the response by using the getLogs method. Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.

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
}
Field Description
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

Field Description
userID
string

userID of the requested user

clusterName
string

Cluster on which the user data 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:

Field Description
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?