Skip to main content
Required ACL: search Use this method to debug the relevance of a specific record. This method accepts a condition and returns the first matching object along with its position information in the result set. The findObject method uses search internally so it can also retrieve the position for a given query. For simply retrieving an object, use the more efficient getObjects method instead.

Examples

index.FindObject<Employee>(
  hit => hit.Firstname.Equals("Jimmie"),
  new Query());

// With a query
index.FindObject<Employee>(
  hit => hit.Firstname.Equals("Jimmie"),
  new Query("query string"));

// With a query and only in the first page
index.FindObject<Employee>(
  hit => hit.Firstname.Equals("Jimmie"),
  new Query("query string"),
  false);

Parameters

callback
function
required
The callback used to find the object.
index
string
required
Scala only: the name of the index to query.
paginate
boolean
default:true
Whether to paginate the search results.
query
string
The query used to search.
requestOptions
object
A mapping of request options, when using this method.

Response

object
object
The hit matching your callback.A hit is made of the schemaless JSON object that you stored in the index.However, Algolia enriches them with additional fields like _highlightResult.Example:
JSON
object: {
    field1 : "",
    field2 : "",
    [...],

    _highlightResult: {
      [...]
    }
}
page
integer
Number of the current page (zero-based). See the page search parameter.
position
integer
Number of the matching object’s position in the result set (zero-based).

Response as JSON

This section shows the JSON response returned by the API. Each API client wraps this response in language-specific objects, so the structure may vary. To view the response, use the getLogs method. Don’t rely on the order of properties—JSON objects don’t preserve key order.
JSON
{
  "object": {
    "firstname": "Jimmie",
    "lastname": "Barninger",
    "_highlightResult": {
      "firstname": {
        "value": "<em>Jimmie</em>",
        "matchLevel": "partial"
      },
      "lastname": {
        "value": "Barninger",
        "matchLevel": "none"
      },
      "company": {
        "value": "California <em>Paint</em> & Wlpaper Str",
        "matchLevel": "partial"
      }
    }
  },
  "position": 0,
  "page": 0
}
I