-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
594: Add searchCutoffMs setting support r=curquiza a=danFbach # Pull Request ## Related issue Fixes #536 ## What does this PR do? - implements searchCutoffMs ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Co-authored-by: Dan Fehrenbach <[email protected]> Co-authored-by: Clémentine <[email protected]>
- Loading branch information
Showing
5 changed files
with
123 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Net.Http.Json; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Meilisearch | ||
{ | ||
public partial class Index | ||
{ | ||
|
||
/// <summary> | ||
/// Gets the search cutoff in milliseconds. | ||
/// </summary> | ||
/// <returns>Returns the search cutoff in milliseconds.</returns> | ||
public async Task<int?> GetSearchCutoffMsAsync(CancellationToken cancellationToken = default) | ||
{ | ||
return await _http.GetFromJsonAsync<int?>($"indexes/{Uid}/settings/search-cutoff-ms", cancellationToken: cancellationToken) | ||
.ConfigureAwait(false); | ||
} | ||
/// <summary> | ||
/// Sets the search cutoff in milliseconds. | ||
/// </summary> | ||
/// <param name="searchCutoffMs">The search cutoff in milliseconds.</param> | ||
/// <param name="cancellationToken">The cancellation token for this call.</param> | ||
/// <returns>Returns the task info of the asynchronous task.</returns> | ||
public async Task<TaskInfo> UpdateSearchCutoffMsAsync(int searchCutoffMs, CancellationToken cancellationToken = default) | ||
{ | ||
var responseMessage = | ||
await _http.PutAsJsonAsync($"indexes/{Uid}/settings/search-cutoff-ms", searchCutoffMs, Constants.JsonSerializerOptionsRemoveNulls, cancellationToken: cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
return await responseMessage.Content.ReadFromJsonAsync<TaskInfo>(cancellationToken: cancellationToken) | ||
.ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// Resets the search cutoff in milliseconds. (default: 1500) | ||
/// </summary> | ||
/// <param name="cancellationToken">The cancellation token for this call.</param> | ||
/// <returns>Returns the task info of the asynchronous task.</returns> | ||
public async Task<TaskInfo> ResetSearchCutoffMsAsync(CancellationToken cancellationToken = default) | ||
{ | ||
var responseMessage = await _http.DeleteAsync($"indexes/{Uid}/settings/search-cutoff-ms", cancellationToken) | ||
.ConfigureAwait(false); | ||
return await responseMessage.Content.ReadFromJsonAsync<TaskInfo>(cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters