Getting documents

This topic describes how to retreive documents from the index using the Client interface.

How it works

You can retrieve indexed objects using the IClient interface Get method. This method requires a type (as a type parameter) and an ID, and returns the indexed object of that type, or null if no document is found with that ID and type.

One of the Get method overloads also accepts a list of ids. Moreover, an extension method with the same name accepts a list of IDs as params. These methods return an IEnumerable of GetResult, which contains information about whether the document was found and, if found, the indexed object.

Note: While indexed objects can be returned as the same type as they were before they were indexed, only the values of public properties with both a getter and a setter are populated by default.

GetWithMeta

The IClient interface has another method for getting indexed objects: GetWithMeta. This method returns the indexed object wrapped in a GetResult object. A typical use case for this method is to retrieve the object along with its version number, which you can use in optimistic concurrency checks (that is, updating objects only if they haven't changed since being fetched).

Classes without parameter-less constructors

You might not be able to de-serialize types without parameter-less constructors or outer dependencies. In many cases, that is a sign that the types are not suitable to use as search results. In these cases, it is probably better to only fetch their IDs and then get them from the database or other backing store, or project their values using the Select method. However, by adding to Client class conventions, you can customize how instances of a specific class are created.