Code Monkey home page Code Monkey logo

meilisearch-dotnet's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

meilisearch-dotnet's Issues

Make the usage easier

Make the package easy to use. The getting started should be:

Meilisearch ms = new Meilisearch("http://localhost:7700", "masterKey");
Index index = await ms.createIndex("books")
var updateStatus = await index.AddorUpdateDocuments(new[]{new  Movie {Id = "1", Name = "Batman"}});

πŸ™‚

Add client.DeleteIndex method

Currently, the only way to delete an index is from an Index instance like:

index.Delete();

We should be able to delete an Index from the client instance:

client.DeleteIndex("indexUID");

Set SearchQuery.Filters type to be a string

The MeiliSearch documentation specify that the SearchQuery.Filters property is of type string and not array of string : https://docs.meilisearch.com/guides/advanced_guides/search_parameters.html#filters

The associated type of this property should be changed and test updated to cover this. Without this change, it's impossible to use this field (at least with the version 0.17.0 that i have on my laptop).

Note : I'll take time to do a PR in order to fix that.

Method to get all the indexes should return a list of instance

Currently, the get_all_indexes method returns a raw list of object, but not a list of Index instance. This is the only index-related method that does not return an Index instance.

An instance is more convenient to manipulate than a raw object. See this example.

TODO

  • Change the return of the current get_all_indexes: make it return a list of Index instances
  • Provide get_all_raw_indexes: a method that returns the list of object of indexes, so the response of the MeiliSearch server.
  • Add tests

⚠️ No code duplication: use get_all_raw_indexes in get_all_indexes.

Related to meilisearch/integration-guides#122

⚠️ Also, this issue is generated, and get_all_indexes might be named differently in this package. Keep the already existing way of naming in this package to stay idomatic with the language and the repository.

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue.

Search option pagination problem based on number of matches

We are using the search option with the Offset & Limit properties for the use of pagination using the below code snippet.

var searchQuery = new SearchQuery
{
AttributesToHighlight = new string[] { "title", "description", "updates" },
AttributesToCrop = new string[] { "description", "updates" },
CropLength = 90,
Offset = startIndex,
Limit = pageSize,
Filters = string.IsNullOrWhiteSpace(filterQuery) ? null : filterQuery,
};

            var searchResponse = await index.Search<FormattedSearchResult>(keyword, searchQuery).ConfigureAwait(false);
TotalCount = searchResponse.NbHits;

Based on the change in the Offset & Limit values i.e., startIndex and pageSize the response value for the number of matches property β€œNbHits” keeps changing for the same searchQuery parameters as mentioned above. Find the result screenshot we had based on this.

Offset – 0 & Limit – 10.

image

Offset – 10 & Limit – 10.

image

As it can be seen above from the screenshots values of the NbHits property varies while increasing the Offset value for the same query & search parameters. This makes the pagination improper for the same search keyword and search parameters. We are using Meilisearch version 0.20.0. And meilisearch dotnet version is 0.4.2

Is this an existing bug.? Or Any work around available for this issue.?

Documents methods should accept an int or a string

With:

public class Movie
{
    public int Id { get; set; }
    public string Name { get; set; }
}
MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterKey");
var index = client.CreateIndex("movies");
var documents = new Movie[] {
    new Movie {Id = 1, Name = "Batman"}
};
var updateStatus = await index.AddDocuments<Movie>(documents);
Movie movie = await index.GetDocument<Movie>(1);

I got the error "impossible to convert int into a string".
The GetDocument method should be able to accept an int or a string since MeiliSearch can accept a string or an int as a document identifier.

TODO:

  • Fix in the code
  • Add tests

GetOrCreateIndex implementation

In the below implementation we're trying to create index with given name, if we get an exception that matches specific exception message we try getting index. Instead of that wouldn't it be good to first try getting index if the result is null then trying to create a new index? In that case we'll also decrease call/request counts in case of index is already exists.

public async Task<Index> GetOrCreateIndex(string uid, string primaryKey = default)
{
try
{
return await this.CreateIndex(uid, primaryKey);
}
catch (Exception e)
{
if (e.Message == "Not able to create index. May be Index already exist")
{
return await this.GetIndex(uid);
}
else
{
throw e;
}
}
}

My suggested implementation:

private async Task<Index> GetOrCreateIndex(string uid)
{
  var index = await _client.GetIndex(uid);
  if (index == null)
  {
      index = await _client.CreateIndex(uid);
  }

  return index;
}

Creating/Deleting indexes in meilisearch server results in IP down

We are trying to create new index or delete existing from the client using the below code.

Create index using below methods

MeilisearchClient client = new MeilisearchClient(ConfigurationManager.AppSettings["SearchURL"],ConfigurationManager.AppSettings["SearchKey"]);
var newIndex = await client.CreateIndex("testing");
var Index = await client.GetOrCreateIndex("testing").ConfigureAwait(false);

While calling the above methods to create the index, the hosted URL(SearchURL) goes down result in the timeout. We then have to start/stop the meilisearch server to enable the hosted URL to access the search. We are using the nuget Meilisearch Dotnet version - 0.4.2.(Meilisearch version 0.20.0) Meilisearch server in which we have hosted the SearchURL is in OS:Debian we have Same problem arises while deleting any of the existing index as well.

Anyone have an idea regarding this.?

Change master branch to main

Let's be allies and make this change that means a lot.

Here is a blog post that explain a little more why it's important, and how to easily do it. It will be a bit more complicated with automation, but we still should do it!

Add method to get the raw index information

⚠️ This issue is generated, it means the examples and the namings do not necessarily correspond to the language of this repository.
Also, if you are a maintainer, feel free to add any clarification and instruction about this issue.

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue in the repo.

Related to meilisearch/integration-guides#120


This SDK provides a method to get an index (getIndex) and this method returns an instance of Index. Some users want to get the raw version of the index, I mean the exact JSON response returned by the MeiliSearch server, not an instance.

Some SDKs already provide a way to get this raw index information but this is not convenient, example in PHP:

$client->index('movies')->fetchRawInfo();

We need to add the getRawIndex method, accessible from the Client instance, to make it more convient.

Prototype:

getRawIndex(string indexUID) -> object/struct/dict of the MeiliSearch response

Ex in PHP:

$client->getRawIndex('movies');

TODO:

  • Add getRawIndex() method to the Client instance without duplicating the code (if fetchRawInfo() already exists for example)
  • Add tests

Remove indexes after running tests

We should erase the indexes present in the MeiliSearch instance before starting the tests: this is dangerous because we run the test in a context we don't know.
This issue is not a problem on the CI, but is not really convenient when running tests locally.

Error in driving operation meilishearch

MeilisearchClient client = new MeilisearchClient("http://xxxxxx:7700", "masterKey");

var index = await client.GetAllIndexes();
var ceshi = await client.CreateIndex("movies1", "Id")

Error when getting all indexes:
System.MissingMethodException:β€œMethod not found: 'System.IO.Stream System.Text.Encoding.CreateTranscodingStream(System.IO.Stream, System.Text.Encoding, System.Text.Encoding, Boolean)'.”

The data can be returned normally by using the post man test request interface:

It may be a problem with the return value

Create and fill sample file to display .NET examples in MeiliSearch Documentation

Code Samples for MeiliSearch documentation

Introduction

As MeiliSearch grows so does its SDK's. More and more SDK's rises from the ground and they all deserve to be as well documented as the core engine itself.

The most common way for a user to understand MeiliSearch is to go to its official documentation. As of yesterday all examples in the documentation were made with cURL. Unfortunately, most of our users do not communicate with MeiliSearch directly with cURL. Which forces them to search for the specific references somewhere else (in the readme's, in the sdk's code itself,..). This makes for unnecessary friction.

Goal

We want our documentation to include all SDK's

As a first step we want all examples to be made using the most possible SDK's. As did Stripe and Algolia.

sdk_sample

examples with curl, javascript and soon enough this SDK too!

To achieve this it is expected from this SDK to create a sample file containing all the code samples needed by the documentation.

These are the steps to follow:

  • Create your sample file
  • Fill your sample file
  • Add your samples to the documentation

Create your sample file

The sample file is a yaml file added at the root of each MeiliSearch SDK.
Sample files are created based on the sample-template.yaml file.

sample-template file:

get_one_index_1: |-
list_all_indexes_1: |-
create_an_index_1: |-
...

This template is accessible publicly here or in the public directory : .vuepress/public/sample-template.yaml of the documentation.

The name of the file should be .code-samples.meilisearch.yaml

Fill your sample file

After creating the sample file with the content of the sample template you should have a file containing all the sampleId's.

get_one_index_1: |-
list_all_indexes_1: |-
create_an_index_1: |-
...

By the name of the different sampleId you should know where that code sample will be added to the documentation.

For example, create_an_index_1 is the first example in the API References of the index creation.

Using the already existing cURL example in the documentation you should see what is expected from that sample. It is very important that you look at the already existing samples in the documentation as it gives you the parameters to use in your sample to match with the rest of the documentation.

Good sample based on documentation:

create_an_index_1: |-
  client.createIndex({ uid: 'movies' })

Bad sample that does not match with the response.

create_an_index_1: |-
  client.createIndex({ uid: 'otherName' })

Each sample is expected to be written in the respective SDK language.

Javascript example:

get_one_index_1: |-
  client.getIndex('movies').show()
list_all_indexes_1: |-
  client.listIndexes()
create_an_index_1: |-
  client.createIndex({ uid: 'movies' })
  ...

The complete cURL sample file is available at the root of the documentation repository.
Every other SDK sample file should be available at the root of their respective repository.

Formatting Exception

There is one exception to the formatting rule.
When the sampleId finishes with _md it means it is expected to be written in markdown format.

JavaScript sample id with _md extension:
yaml-js-example

Add your samples to the documentation

Once your sample file is filled with the code samples, you will need to create a pull request on the documentation repository.

Open the following file in your IDE:
.vuepress/code-samples/sdks.json

And add your sample file to the list:

[
  ...
  {
    "language": "sdk-language",
    "label": "sdk-label",
    "url": "url to yaml file"
  }
]

The language key expect a supported language for the code highlight.

The label key is the name of the tab. While label and language could have been the same, it created some conflict (i.e: bash and cURL).

The url is the raw link to access your sample file. It should look like this:
https://raw.githubusercontent.com/[PROJECT]/[REPO]/.code-samples.meilisearch.yaml

`UpdateIndex()` method

TODO:

  • Currently we have the UpdateIndex() method in the Index class. This method should be renamed as Update().
  • Add a method named UpdateIndex() in the Client class, calling the Update() newly created in Index.
  • Add tests and adapt the current ones.

Add a method to delete the index only if it already exists

Trying to delete an index that does not exist on the MeiliSearch server will throw an error. To delete it without any error no matter what if it exists or not, we need a new method.

  • Add a method delete_index_if_exists: it deletes the index but does not throw any error if the index does not exist.
  • Add tests

Example: https://github.com/meilisearch/meilisearch-python/pull/268/files

⚠️ This issue is generated, and delete_index_if_exists might be named differently in this package. Keep the already existing way of naming in this package to stay idomatic with the language and the repository.

Related to meilisearch/integration-guides#107

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue.

Index stat total documents count mismatch?

We have created an index in our meilisearch server and pushed bulk data from our database into the index. We are using the meilisearch version - 0.20.0 The current number of documents we have retried from the below code is 76,252.

var stats = await client.Index(index).GetStats();
Console.WriteLine(stats.NumberOfDocuments);

After that we pushed two batches of data each containing 96 & 4 documents each. So totally 100 documents pushed to the index. But when we checked the documents using the above code. Count has increased to 76,259. Remaining 93 counts are not retrieved from the stats of the index.

We have also checked the status of the update ID's of the above two batches(96 & 4) using the below code and it is marked as "Processed".

var updateStatus = await client.Index(index).GetUpdateStatus(updateId);
Console.WriteLine(updateStatus.Status);

Is there any delay in moving the processed updated Id documents into the "GetStats()" method "NumberOfDocuments" property as we are facing a discrepancy of 93 records.? Please provide any insight on this.

Remove Microsoft.AspNetCore.WebUtilities to increase the surface area of the project

Hello!

I was having a peek at the dependencies of this project, and I encountered the Microsoft.AspNetCore.WebUtilities dependency. This dependency has itself 2 dependencies on other projects..

What is the reason for this package? As far as I can see, it is only used to generate some query strings:

uri = QueryHelpers.AddQueryString(uri, new { primaryKey = primaryKey }.AsDictionary());

I believe these do not belong in this library for several reasons:

  • I see this library as general purpose; any type of project should be able to use it. So why do we have an AspNetCore package dependency?
  • Why introduce a dependency to generate some ?query=strings&and=stuff? :) This can easily be done with normal C#.

Removing this dependency will increase the surface area that cna be reached with this library because it needs fewer dependencies to function and could increase adoption by removing a "wonky" dependency :)

Find a way to fix the flacky test

Randomly, the CI makes the tests fails
see: https://github.com/meilisearch/meilisearch-dotnet/runs/3896895492

√ Meilisearch.Tests.IndexTests.UpdatePrimaryKey [18ms]
[xUnit.net 00:00:03.15]     Meilisearch.Tests.MeilisearchClientTests.GetDumpStatusById [FAIL]
[xUnit.net 00:00:03.15]       Expected dumpStatus.Status to be "done" with a length of 4, but "in_progress" has a length of 11, differs near "in_" (index 0).
[xUnit.net 00:00:03.15]       Stack Trace:
[xUnit.net 00:00:03.15]            at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message)
[xUnit.net 00:00:03.15]            at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
[xUnit.net 00:00:03.16]            at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)
[xUnit.net 00:00:03.16]            at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
[xUnit.net 00:00:03.16]            at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc)
[xUnit.net 00:00:03.16]            at FluentAssertions.Primitives.StringEqualityValidator.ValidateAgainstLengthDifferences()
[xUnit.net 00:00:03.16]            at FluentAssertions.Primitives.StringValidator.Validate()
[xUnit.net 00:00:03.16]            at FluentAssertions.Primitives.StringAssertions`1.Be(String expected, String because, Object[] becauseArgs)
[xUnit.net 00:00:03.16]         /home/runner/work/meilisearch-dotnet/meilisearch-dotnet/tests/Meilisearch.Tests/MeilisearchClientTests.cs(87,0): at Meilisearch.Tests.MeilisearchClientTests.GetDumpStatusById()
[xUnit.net 00:00:03.16]         --- End of stack trace from previous location where exception was thrown ---

The dump creation is not finished and that's why the dump fails.
We should find a way to avoid this random failure.

Add methods to automatically add/update documents in batches

We need methods to add and update the documents of MeiliSearch in batch instead of letting the users call addDocuments in a loop.

  • Add addDocumentsInBatches
addDocumentsInBatches(documents, batchSize = 1000, primaryKey = nil)

batchSize and primaryKey are optional parameters

  • Add updateDocumentsInBatches
updateDocumentsInBatches(documents, batchSize = 1000, primaryKey = nil)

batchSize and primaryKey are optional parameters

  • Add tests

Example: meilisearch/meilisearch-python#260

⚠️ This issue is generated, it means addDocumentsInBatches andd updateDocumentsInBatches might be named differently in this package. Keep the already existing way of naming in this package to stay idiomatic with the language and the repository.
Also, if you are a maintainer, feel free to add any clarification and instruction about this issue related to the specific languages of the repo.

Related to meilisearch/integration-guides#106

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue in the repo.

NDJSON/CSV methods to add and update documents

⚠️ This issue is generated, it means the nameing might be done differently in this package (ex: add_documents_json instead of addDocumentsJson). Keep the already existing way of naming in this package to stay idiomatic with the language and this repository.

πŸ“£ We strongly recommend doing multiple PRs to solve all the points of this issue

MeiliSearch v0.23.0 introduces two changes:

  • new valid formats to push data files, additionally to the JSON format: CSV and NDJSON formats.
  • it enforces the Content-type header for every route requiring a payload (POST and PUT routes)

Here are the expected changes to completely close the issue:

  • Currently, the SDKs always send Content-Type: application/json to every request. Only the POST and PUT requests should send the Content-Type: application/json and not the DELETE and GET ones.

  • Add the following methods and πŸ”₯ the associated tests πŸ”₯ to ADD the documents. Depending on the format type (csv or ndjson) the SDK should send Content-Type: application/x-dnjson or Content-Type: text/csv)

    • addDocumentsJson(string docs, string primaryKey)
    • addDocumentsCsv(string docs, string primaryKey)
    • addDocumentsCsvInBatches(string docs, int batchSize, string primaryKey)
    • addDocumentsNdjson(string docs, string primaryKey)
    • addDocumentsNdjsonInBatches(string docs, int batchSize, string primaryKey)
  • Add the following methods and πŸ”₯ the associated tests πŸ”₯ to UPDATE the documents. Depending on the format type (csv or ndjson) the SDK should send Content-Type: application/x-dnjson or Content-Type: text/csv)

    • updateDocumentsJson(string docs, string primaryKey)
    • updateDocumentsCsv(string docs, string primaryKey)
    • updateDocumentsCsvInBatches(string docs, int batchSize, string primaryKey)
    • updateDocumentsNdjson(string docs, string primaryKey)
    • updateDocumentsNdjsonInBatches(string docs, int batchSize, string primaryKey)

docs are the documents sent as String
primaryKey is the primary key of the index
batchSize is the size of the batch. Example: you can send 2000 documents in raw String in docs and ask for a batchSize of 1000, so your documents will be sent to MeiliSearch in two batches.

Example of PRs:


Related to: meilisearch/integration-guides#146

If this issue is partially/completely implemented, feel free to let us know.

EDIT:

The files needed for the tests when creating the csv and ndjson methods are available here:

Missing routes need to be implemented

Some routes present in MeiliSearch are not implemented in this package yet:

The settings routes and sub-routes are the most urgent ones πŸ™‚

⚠️ Tests should be added for each newly implemented route.

Improve search tests

This issue is to improve the tests relative to the Search method. It means improving this file by adding tests:

  • do tests about all the search parameters. For example, there are no tests about the crop.
    - add better Filters tests with AND and OR (see the end of this page of docs)

This file might need changes to fit those new tests.

A basic error handler

We should add a basic error handler, with these 2 custom errors:

  • MeiliSearchApiError
  • MeiliSearchCommunicationError

If I'm not wrong, @barbados-clemens you created one in your previous meilisearch-dotnet repo (not available anymore) πŸ™‚
Was this complicated to add?

FYI: Even if it's not documented yet, MeiliSearch API has a great error handler, and returns this kind of JSON when an error is found:

Capture d’écran 2020-07-02 aΜ€ 10 18 21

It could be great to let the user access message, errorCode, errorType and errorLink.

Code for Searchable attributes

Hi,

Can you add code to get/set Searchable attributes
I suggest the following to go into Index.cs

`
///


/// Update searchable attributes.
///

/// strings that contains searchable attributes sorted by order of importance (arranged from the most important attribute to the least important attribute).
/// Returns the updateID of this async operation.
/// Even if the document class properties are in upper/mixed case the attributes should be in lower case.
public async Task UpdateSearchableAttributes(IEnumerable attributes)
{
var responseMessage = await this.client.PostAsJsonAsync($"/indexes/{this.Uid}/settings/searchable-attributes", attributes);
return await responseMessage.Content.ReadFromJsonAsync();
}

    /// <summary>
    /// Get searchable attributes.
    /// </summary>
    /// <returns>An Ienumerable of strings that contains searchable attributes sorted by order of importance (arranged from the most important attribute to the least important attribute).</returns>
    public async Task<IEnumerable<string>> GetSearchableAttributes()
    {
        return await this.client.GetFromJsonAsync<List<string>>($"/indexes/{this.Uid}/settings/searchable-attributes");
    }

`

Add a search example with `filter` in README

⚠️ This issue is generated, please adapt the example to the repository language.

Related to: meilisearch/integration-guides#136

In the README, we want to add the Custom Search With Filters sub section in the Getting Started section to make the users are aware of filtering.

This should

  • be placed right after the Custom Search sub section
  • contain the following content:

---------- beginning of the content

If you want to enable filtering, you must add your attributes to the filterableAttributes index setting.

--- Add an example corresponding to the current repository. See this example in JS:

await index.updateAttributesForFaceting([
    'id',
    'genres'
  ])

--- end of example

You only need to perform this operation once.

Note that MeiliSearch will rebuild your index whenever you update filterableAttributes. Depending on the size of your dataset, this might take time. You can track the process using the update status.

Then, you can perform the search:

--- Add an example corresponding to the current repository. See this example in JS:

await index.search(
  'wonder',
  {
    filter: ['id > 1 AND genres = Action']
  }
)

--- end of example

{
  "hits": [
    {
      "id": 2,
      "title": "Wonder Woman",
      "genres": ["Action","Adventure"]
    }
  ],
  "offset": 0,
  "limit": 20,
  "nbHits": 1,
  "processingTimeMs": 0,
  "query": "wonder"
}

------------- end of the content

πŸ“£ Example of PR: https://github.com/meilisearch/meilisearch-js/pull/1059/files

Use ConfigureAwait(false) to improve performance of the library

Please read:

https://github.com/Microsoft/vs-threading/blob/main/doc/cookbook_vs.md#should-i-await-a-task-with-configureawaitfalse
https://medium.com/bynder-tech/c-why-you-should-use-configureawait-false-in-your-library-code-d7837dce3d7f

Not using ConfigureAwait(false) in a library that might be used by an app that has a SynchronizationContext could result in a loss of performance and perhaps some issues.

This library should use ConfigureAwait(false) everywhere to prevent this

The UpdateDocuments method should be a partial update

Currently when doing this test:

var indexUID = "BasicDocumentsUpdateTest";
Index index = await this.client.GetOrCreateIndex(indexUID);

// Add the documents
UpdateStatus update = await index.AddDocuments(new[]
{
    new Movie { Id = "1", Name = "Batman", Genre = "Action" },
    new Movie { Id = "2", Name = "Superman" }
});

// Update the documents
update = await index.UpdateDocuments(new[] { new Movie { Id = "1", Name = "Ironman" } });

// Check the documents have been updated and added
var docs = await index.GetDocuments<Movie>();
Assert.Equal("1", docs.First().Id);
Assert.Equal("Ironman", docs.First().Name);
Assert.Equal("Action", docs.First().Genre);
Assert.Equal("2", docs.ElementAt(1).Id);
Assert.Equal("Superman", docs.ElementAt(1).Name);
docs.ElementAt(1).Genre.Should().BeNull();

The Assert.Equal("Action", docs.First().Genre); line fails because Genre is null but it should not be. The add-or-update-documents route should be a partial update, so the value a Genre should still be "Action".

Change `books` to `movies` in README.md

To keep the getting started simple to try, but to also make documentation examples compatible with the getting started, we are replacing book examples with movies examples.

The Movie dataset is used throughout the documentation. The only place where book is used is in the tests (which can stay as it is) and in our getting started.

Changes

  • Index name should be changed in README.md
  const index = client.index('movies')

Provided dataset should be changed with the following:

 const documents = [
      { id: 1, title: 'Carol', genres: ['Romance', 'Drama'] },
      { id: 2, title: 'Wonder Woman', genres: ['Action', 'Adventure'] },
      { id: 3, title: 'Life of Pi', genres: ['Adventure', 'Drama'] },
      { id: 4, title: 'Mad Max: Fury Road', genres: ['Adventure', 'Science Fiction'] },
      { id: 5, title: 'Moana', genres: ['Fantasy', 'Action']},
      { id: 6, title: 'Philadelphia', genres: ['Drama'] },
  ]
  • comment should be changed
// If the index 'movies' does not exist, MeiliSearch creates it when you first add the documents.
  • All the other examples in the README should be updated accordingly

GetIndex should return the same object as CreateIndex

According to the Getting Started, I can write:

MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterKey");
var index = client.CreateIndex("movies");
var documents = new Movie[] {
    new Movie {Id = "1", Name = "Batman"},
    new Movie {Id = "2", Name = "Interstellar"},
    new Movie {Id = "3", Name = "Batman Begins"}
};
var updateStatus = await index.AddDocuments<Movie>(documents);

but I cannot write:

MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterKey");
var index = client.GetIndex("movies");
var documents = new Movie[] {
    new Movie {Id = "1", Name = "Batman"},
    new Movie {Id = "2", Name = "Interstellar"},
    new Movie {Id = "3", Name = "Batman Begins"}
};
var updateStatus = await index.AddDocuments<Movie>(documents);

Because 'Task<Index>' does not contain a definition for AddDocuments.

If the index is already created, I should have the possibility to use GetIndex instead of CreateIndex to manipulate my already existing index in the same way πŸ™‚
Both methods should return the same object.

TODO:

  • Add this feature in the code
  • Add tests

Add `updatedAt` and `createdAt` to `Index`

When manipulating indexes (get/create/update), the MeiliSearch server returns the following information related to the index:

  • uid: the uid of the index
  • primaryKey: the primary key of the index
  • updateAt: when the index has been updated
  • createdAt: when the index has been created

This SDK, when manipulating indexes (get/create/update) returns an instance of Index which already contains the primaryKey and uid members.

It means we can currently get the primaryKey and the uid, but not updatedAt and createdAt.

TODO:

  • Add updatedAt and createdAt member in the Index class/struct (depending on the language).
  • Update the variable in the code where primaryKey is already updated. Ex: when getting the index with getIndex()
  • Add tests

⚠️ This issue is generated, it means primaryKey, updatedAt, and createdAt might be named differently in this package (ex: primary_key instead). Keep the already existing way of naming in this package to stay idiomatic with the language and the repository.
Also, if you are a maintainer, feel free to add any clarification and instruction about this issue related to the specific languages of the repo.

Related to meilisearch/integration-guides#121

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue in the repo.

Implement dumps

Since v0.15.0, MeiliSearch exposes a new functionality: dumps

This feature should be implemented in this SDK following this specificacions

  • Implement dump creation route
  • Implement get dump status route
  • Add tests
    - [ ] Add code samples not available for this SDK

Linter

We should add a linter to this project, at least for the code style.

For example, I can see here the same kind of method but with not the same style (especially in the name of the function):

[Fact]
public async Task Should_be_Able_to_add_Document_for_Index()
{
var updateStatus = await index.AddorUpdateDocuments(new[] {new Movie {Id = "1", Name = "Batman"}});
updateStatus.UpdateId.Should().BeGreaterOrEqualTo(0);
}
[Fact]
public async Task Should_be_Able_to_Get_One_Document_With_Id()
{
var documents = await index.GetDocument<Movie>("10");
documents.Id.Should().Be("10");
}
[Fact]
public async Task Should_Be_able_to_get_Many_documents_By_Limit()
{
var documents = await index.GetDocuments<Movie>(new DocumentQuery {Limit = 1});
documents.Count().Should().Be(1);
}

The goal is to provide a better environment for contribution πŸ™‚

I'm not a .NET dev, so I'm not aware of the lint tools in .NET. What do you suggest?

NB: I'm adding an editorconfig file in this PR #8 but it's just about general style indentation.

Refactor the way of handling HTTP request?

In #165 I implemented an HttpRequest class to implement our own HTTP methods (PostAsJsonAsync...) to remove the charset-utf8 content type.

However, I'm not a c# dev, and I feel like I missed something: at first I wanted to "extend" the HttpClient class and override PostAsJsonAsync, but without any success. So I came to the current implementation you can find in the main branch.

Does anyone know a better way to implement this?

Feel free to open any PR!

Implement sub-settings methods

Currently only GetSettings, UpdateSettings and ResetSettings are implemented. These routes manage all the settings by calling this "general" settings route.

But currently in this SDK, no method are implemented to call the sub-routes of each settings.
We need to add the GetXXX, UpdateXXX and ResetXXX where XXX are the following settings:

⚠️ Tests should be added for each method

No need to do all the settings in the same PRs of course, any contributions, even small, are welcome πŸ˜‡β€οΈ
Feel free to ask any question!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.