API client / Methods / Search
Required API Key:
Method signature
SearchIndex::getObjectPosition(object results, string objectId)

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.

About this method

Retrieve the given object’s position in the given results set. Can be used to debug relevance.

getObjectPosition may be used to debug the relevance of an objectID in specific results set. If the objectID is found, the position of the object is returned.

Examples

Read the Algolia CLI documentation for more information.

1
$position = SearchIndex::getObjectPosition($results, 'a-unique-identifier');

Parameters

Parameter Description
results
type: key/value mapping
Required

The results set of a search.

objectId
type: string
Required

The objectID of the record.

class
type: class
Required

Only for Java and Scala: the type of the hits.

Response

This method doesn't return a response.

Did you find this page helpful?