🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API client / Methods / MultiClusters
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,
])

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

About this method # A

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 # A

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 # A

Parameter Description
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 # A

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 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:

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?
PHP v3