Write async
Describe async methods for write operation
UpdateAsync()
Perform a non-blocking updates an existing document to the backend.
- Parameters: Require a document id (DocumentId). We have some other overloading methods allowing pass more parameters.
- Return value: return an awaitable Task.
_searchClient.UpdateAsync<MyDocument>("your_existing_document_id", new UpdateRequestBody({//your document's fields}));
IndexAsync()
Perform a non-blocking index document or a bulk of documents to the store.
- Parameters: Require a document object. We have some other overloading methods for passing different type of parameters.
- Return value:
- Indexing a single document will return an awaitable
Task<IndexResult>
. - Indexing a bulk documents will return an awaitable
Task<BulkResult>
.
- Indexing a single document will return an awaitable
await _searchClient.IndexAsync(new MyDocument());
DeleteByQueryAsync()
Perform a non-blocking delete documents. We perform a "search and then delete" based on your matching documents by your query.
- Parameters: Require a IQuery object.
- Return value: Return an awaitable
Task<DeleteByQueryResult>
.
var query = new IdsQuery("1", "4", "100");
_searchClient.DeleteByQueryAsync(query, null);
//if you're using our ClientExtensions just call
_searchClient.DeleteAsync<MyDocument>(x => x.Name.Match("alloy"));
TrackAsync()
Perform an asynchronous track query to FIND service. It will store a track document in your statistics index.
- Return an awaitable Task, TrackQueryResult contains a track id when successfully.
This is used in Track() extension method and you do not need to care much about this except that Track will be perform in a separate thread.
_searchClient.Search<ArticlePage>()
.For("alloy")
.Track() //perform a non-blocking track to FIND (TrackQueryAsync)
.GetResultAsync();
TrackHitAsync()
Perform an increasement for a track, this is usually used for the click calculation.
- Parameters:
- Required parameters: The query string and the hit id are required.
- Optional parameter: An action for the TrackHitCommand.
- Return value: Return an awaitable
Task<TrackHitResult>
.
using EPiServer.Find.Statistics;
await _searchClient.Statistics().TrackHitAsync("query", "type/hit_id");
Updated 3 months ago