Coder Social home page Coder Social logo

meilisearch / meilisearch-dart Goto Github PK

View Code? Open in Web Editor NEW
74.0 74.0 27.0 1.01 MB

The Meilisearch API client written for Dart

Home Page: https://meilisearch.com

License: MIT License

Dart 100.00%
client dart flutter meilisearch meilisearch-dart sdk

meilisearch-dart's Introduction

Meilisearch

Meilisearch Dart

Pub Version GitHub Workflow Status License Bors enabled Code Coverage

⚑ The Meilisearch API client written in Dart

Meilisearch Dart is the Meilisearch API client for Dart and Flutter developers.

Meilisearch is an open-source search engine. Learn more about Meilisearch.

Table of Contents

πŸ“– Documentation

This readme contains all the documentation you need to start using this Meilisearch SDK.

For general information on how to use Meilisearchβ€”such as our API reference, tutorials, guides, and in-depth articlesβ€”refer to our main documentation website.

⚑ Supercharge your Meilisearch experience

Say goodbye to server deployment and manual updates with Meilisearch Cloud. Get started with a 14-day free trial! No credit card required.

πŸ”§ Installation

You can install the meilisearch package by adding a few lines into pubspec.yaml file.

dependencies:
  meilisearch: ^0.16.0

Then open your terminal and update dart packages.

pub get

Run Meilisearch

There are many easy ways to download and run a Meilisearch instance.

For example, using the curl command in your Terminal:

#Install Meilisearch
curl -L https://install.meilisearch.com | sh

# Launch Meilisearch
./meilisearch --master-key=masterKey

NB: you can also download Meilisearch from Homebrew or APT or even run it using Docker.

πŸš€ Getting started

Add Documents

import 'package:meilisearch/meilisearch.dart';

void main() async {
  var client = MeiliSearchClient('http://127.0.0.1:7700', 'masterKey');

  // An index is where the documents are stored.
  var index = client.index('movies');

  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'] },
  ]

  // If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
  var task = await index.addDocuments(documents); // => { "uid": 0 }
}

With the uid, you can check the status (enqueued, canceled, processing, succeeded or failed) of your documents addition using the task.

Basic Search

// Meilisearch is typo-tolerant:
var result = await index.search('carlo');

print(result.hits);

JSON Output:

[
  {
    "id": 1,
    "title": "Carol",
    "genres": ["Romance", "Drama"]
  }
]

Custom Search

All the supported options are described in the search parameters section of the documentation.

var result = await index.search(
  'carol',
  attributesToHighlight: ['title'],
);

JSON output:

{
    "hits": [
        {
            "id": 1,
            "title": "Carol",
            "_formatted": {
                "id": 1,
                "title": "<em>Carol</em>"
            }
        }
    ],
    "offset": 0,
    "limit": 20,
    "processingTimeMs": 0,
    "query": "carol"
}

Custom Search With Filters

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

await index.updateFilterableAttributes(['id', 'genres']);

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 task status.

Then, you can perform the search:

await index.search('wonder', filter: ['id > 1 AND genres = Action']);
{
  "hits": [
    {
      "id": 2,
      "title": "Wonder Woman",
      "genres": ["Action","Adventure"]
    }
  ],
  "offset": 0,
  "limit": 20,
  "estimatedTotalHits": 1,
  "processingTimeMs": 0,
  "query": "wonder"
}

Advanced Configuration

Customizing the dio instance

Meilisearch uses dio internally to send requests, you can provide it with your own interceptors or adapter using the MeiliSearchClient.withCustomDio constructor.

Using MeiliDocumentContainer

The MeiliDocumentContainer<T> class contains meilisearch-specific fields (e.g. rankingScoreDetails, _formatted, matchesPosition, etc...).

We define the mapToContainer() extension to help you quickly opt-in to this class, example:

final res = await index 
      .search("hello world") 
      .asSearchResult() //or .asPaginatedResult() if using page parameters
      .mapToContainer(); 

πŸ€– Compatibility with Meilisearch

This package guarantees compatibility with version v1.x of Meilisearch, but some features may not be present. Please check the issues for more info.

⚠️ This package is not compatible with the vectoreStore experimental feature of Meilisearch v1.6.0 and later. More information on this issue.

πŸ’‘ Learn more

The following sections in our main documentation website may interest you:

βš™οΈ Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!


Meilisearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.

meilisearch-dart's People

Contributors

ahmednfwela avatar alallema avatar bidoubiwa avatar binaya-mrt avatar bors[bot] avatar brunoocasali avatar curquiza avatar dependabot[bot] avatar mafreud avatar meili-bors[bot] avatar meili-bot avatar reginaalyssa avatar sanders41 avatar sayam06 avatar shakyacsun avatar themisir avatar thicolares avatar

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

Watchers

 avatar  avatar  avatar  avatar

meilisearch-dart's Issues

Implementing tests

General advice/rules:

  • Create independent tests: it means the MeiliSearch instance should be empty (no indexes at all) when you start each test. To implement this, we use fixture in the Dotnet SDK. https://github.com/meilisearch/meilisearch-dotnet/blob/master/tests/Meilisearch.Tests/IndexFixture.cs
  • There should be at least one test for each method. Several with different situations is better of course.
  • Tests are boring to write, but keep in mind it will help you (and us) to accept contributions since you ensure the tests pass. Being able to accept contributions is one of our main concern.

When you’ve done the minimum tests, you might think it misses some deeper tests (for example, testing the search with all the possible parameters). If you are tired of doing tests -> open issues! Community might help us on this!

According to the endpoints you’ve implemented here are the tests. They are integration tests, no unit tests: the goal is to check MeiliSearch and the SDK work perfectly together so it might involve you call another method when testing one specific method.

Indexes:

  • Create index with right UID without any primary passed in parameter
  • Create index with right UID with a primary
  • Update an existing index where the primary has not be set before
  • Delete an existing index
  • Get an existing index
  • Get a non-existing index -> error
  • Get all indexes

Settings:

  • Getting the default settings
  • Update the settings
  • Reseting the settings: it involves update them first, then resetting them and check the default values have been set

Update:

  • Add documents and check an update have been processed

Documents:

  • Add documents
  • Add documents and pass a primary key at the same time
  • Update documents -> it should not overwrite all the updated document, but only the concerned fields
  • Update documents and pass a primary key at the same time
  • Delete one documents
  • Delete multiple documents
  • Delete all documents

Search:

  • search with a basic query, ex: prince
  • search with no q -> should do a placeholder search = return all the docs
  • search with an empty string q="" -> should do a placeholder search too
  • search with some optional paramters. Might be boring, do it only for some of the parameters (limit, offset…) and open issues for the others if you prefer.

Misc:

You might need a waitForPendingUpdate method that make the actions of adding documents and settings asynchronous: this method waits until the update is processed or failed. There is this kind of method in the Dotnet SDK -> Index.cs:232.

Create and fill sample file to display Dart examples in MeiliSearch Documentation

Code Samples for MeiliSearch documentation

Introduction

As MeiliSearch grows so does its SDKs. More and more SDKs rise 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 SDKs code itself,..). This makes for unnecessary friction.

Goal

We want our documentation to include all SDKs

As a first step, we want all examples to be made using the most possible SDKs. 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

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 and 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.

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

Currently, the geAllIndexes 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 geAllIndexes: make it return a list of Index instances
  • Provide geAllRawIndexes: 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

Sorry if this is already partially/completely implemented, feel free to let me know about the state of this issue.
Also, this issue is generated, and getAllIndexes might be named differently in this package

Add new code-samples requested by the Meilisearch v0.29 release

⚠️ 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, please add any clarification and instructions about this issue.

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

Related to meilisearch/integration-guides#213


⚠️⚠️⚠️ This SDK does not have the matchingStrategy yet. To close this issue #207 should be done first.

Add the new code samples into the file .code-samples.meilisearch.yml:

TODO:

  • Add search_parameter_guide_matching_strategy_1
    • Search for big fat liar with "matchingStrategy": "last" in a movies index.
  • Add search_parameter_guide_matching_strategy_2
    • Search for big fat liar with "matchingStrategy": "all" in a movies index.

For example, in Javascript, the code-samples required to fix the issue are:

client.index('movies').search('big fat liar', { matchingStrategy: 'last' }) and also
client.index('movies').search('big fat liar', { matchingStrategy: 'all' })

so the final version inside of the samples should be:

search_parameter_guide_matching_strategy_1: |-
  client.index('movies').search('big fat liar', { matchingStrategy: 'last' })
search_parameter_guide_matching_strategy_2: |-
  client.index('movies').search('big fat liar', { matchingStrategy: 'all' })

Integrating the http/2 protocol into the plugin

Description
Could you add http/2 support to the plugin? I looked at your plugin source code and saw that you are using Dio. on the page of this plugin there is information about using this protocol.

Basic example

dependencies:
  dio: ^4.0.0
  dio_http2_adapter: ^2.0.0

import 'package:dio/dio.dart';
import 'package:dio_http2_adapter/dio_http2_adapter.dart';

  var dio = Dio()
    ..options.baseUrl = 'https://google.com'
    ..interceptors.add(LogInterceptor())
    ..httpClientAdapter = Http2Adapter(
      ConnectionManager(
        idleTimeout: 10000,
        // Ignore bad certificate
        onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
      ),
    );

Implement sub-settings routes

Currently only index.getSettings(), index.updateSettings() and index.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 index.getXXX(), index.updateXXX() and index.resetXXX() where XXX are the following settings:

No need to do it in one big PR, any addition is welcome!
We are really open to contributions! Feel free to ask any questions if anything is not clear πŸ™‚

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 deleteIndexIfExists: 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 deleteIndexIfExists 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.

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.

Add support to the facet setting customization at the index level

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

Related to:


Add a faceting index settings resource to manage customization of the maximum value per facet.

  • Expose faceting object on /indexes/:index_uid/settings endpoints.
  • Add GET/PATCH/DELETE - /indexes/:index_uid/settings/faceting endpoints.

The faceting object definition is made of the following properties:

  • maxValuesPerFacet type (int)

More information about what each field does could be checked in the spec.

Check the other customization methods for reference like: synonyms, searchableAttributes, filterableAttributes.

TODO:

  • Add the new methods to customize faceting
    • GET /indexes/:index_uid/settings/faceting
    • PATCH /indexes/:index_uid/settings/faceting
    • DELETE /indexes/:index_uid/settings/faceting
  • Add tests

Improve test logging by removing a noisy message

The message Using Meilisearch server on http://localhost:7700 for running tests. makes it harder to understand the test running logs.

➜  meilisearch-dart git:(feature/tenant-token) dart test --concurrency=1                            
00:00 +0: test/get_keys_test.dart: Keys When has master key responds with all keys                                                  
Using Meilisearch server on http://localhost:7700 for running tests.
00:00 +1: test/get_keys_test.dart: Keys When has master key gets a key from server by key/uid                                       
Using Meilisearch server on http://localhost:7700 for running tests.
00:00 +2: test/get_keys_test.dart: Keys When has master key creates a new key                                                       
Using Meilisearch server on http://localhost:7700 for running tests.
00:00 +3: test/get_keys_test.dart: Keys When has master key creates a new key with expiresAt                                        
Using Meilisearch server on http://localhost:7700 for running tests.
00:00 +4: test/get_keys_test.dart: Keys When has master key updates a key partially                                                 
Using Meilisearch server on http://localhost:7700 for running tests.
00:00 +5: test/get_keys_test.dart: Keys When has master key updates key expiresAt                                                   
Using Meilisearch server on http://localhost:7700 for running tests.
00:00 +6: test/get_keys_test.dart: Keys When has master key deletes a key                

Without it, we just have a compact log that just shows up the errors and all the other information is hidden (much better).

The idea is to remove this message for every test call, but print once before the whole test suite.

I know we have the setUpAll hook, but to be feasible to use it, I think we will need to improve the whole test suite.

Add support to the typo tolerance customization

⚠️ 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.

Related to:


Add a typoTolerance index settings resource to manage customization of the typo tolerance feature at the index level.

  • Expose typoTolerance object on /indexes/:index_uid/settings endpoints.
  • Add GET/POST/DELETE - /indexes/:index_uid/settings/typo-tolerance endpoints.

The typoTolerance object definition is made of the following properties:

  • enabled type (boolean)
  • disableOnAttributes type (array[string])
  • disableOnWords type (array[string])
  • minWordSizeForTypos type (object)
    • oneTypo type (int)
    • twoTypos type (int)

More information about what each field does could be checked in the spec.

Check the other customization methods for reference like: synonyms, searchableAttributes, filterableAttributes.

TODO:

  • Add the new methods to customize typo-tolerance
    • GET /indexes/:index_uid/settings/typo-tolerance
    • POST /indexes/:index_uid/settings/typo-tolerance
    • DELETE /indexes/:index_uid/settings/typo-tolerance
  • Add tests

Update .code-samples.meilisearch.yaml

⚠️ 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 wholly/partially implemented. Feel free to let me know about the state of this issue in the repo.

Related to meilisearch/integration-guides#185


Check the integration-guides issue for more information and the complete description about what should be done here (each TODO item has its report in the #185).

TODO:

  • New code samples regarding the new getting started
  • Replace description into overview and genre into genres
  • Update geosearch guide
  • Remove unused code samples
  • Update the primary key examples
  • Add settings_guide_sortable_1 code samples
  • Add landing_getting_started_1 code samples

Add support to the pagination setting customization at the index level

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

Related to:


Add a pagination index settings resource to manage customization of the maximum number of reachable documents during the search at the index level.

  • Expose pagination object on /indexes/:index_uid/settings endpoints.
  • Add GET/PATCH/DELETE - /indexes/:index_uid/settings/pagination endpoints.

The pagination object definition is made of the following properties:

  • maxTotalHits type (int)

More information about what each field does could be checked in the spec.

Check the other customization methods for reference like: synonyms, searchableAttributes, filterableAttributes.

TODO:

  • Add the new methods to customize pagination
    • GET /indexes/:index_uid/settings/pagination
    • PATCH /indexes/:index_uid/settings/pagination
    • DELETE /indexes/:index_uid/settings/pagination
  • Add tests

Dart Error: import of dart:mirrors is not supported in the current Dart runtime

Description
import of dart:mirrors is not supported in the current Dart runtime

Expected behavior
should work without any issues.

Current behavior
after import meilisearch in data module.

Screenshots or Logs
E/flutter ( 6594): [ERROR:flutter/shell/common/shell.cc(93)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
E/flutter ( 6594): [ERROR:flutter/runtime/dart_isolate.cc(143)] Could not prepare isolate.
E/flutter ( 6594): [ERROR:flutter/runtime/runtime_controller.cc(385)] Could not create root isolate.
Restarted application in 2,146ms.

Environment (please complete the following information):

  • OS: Kubuntu
  • Meilisearch version: 0.7.0
  • meilisearch-dart version:

Wrong type for search cropLength

Description
cropLength in MeiliSearchIndex accepts a type of List<String>?, but MeiliiSearch expects an integer here resulting in an exception.

Expected behavior
Crop length can be used without an exception.

Current behavior
Preforming a search with a cropLength results in an exception: MeiliSearchApiError - message: Json deserialize error: invalid type: sequence, expected usize at line 1 column 58 - errorCode: bad_request - errorType: invalid_request_error - errorLink: https://docs.meilisearch.com/errors#bad_request

Environment (please complete the following information):

  • MeiliSearch version: v0.21.0
  • meilisearch-dart version: v0.3.0

Test Suite Failure

I was looking at adding some of the methods listed in the issues, and after cloning I ran the test suite to make sure everything was good before making any changes. In doing this I am getting either test failures or the test suite freezes and never finishes.

One weird thing is when it fails I get different results. For example one time I got +16 -23: Some tests failed. and another time I got +18 -21: Some tests failed. . Nothing changed in the code between test runs and I stopped and restarted the MeiliSearch docker container to make sure there was nothing left from the previous run.

I have dart installed through Flutter and the output of flutter doctor -v is

[βœ“] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en-US)
    β€’ Flutter version 2.2.2 at /Users/paul/development/flutter
    β€’ Framework revision d79295af24 (13 days ago), 2021-06-11 08:56:01 -0700
    β€’ Engine revision 91c9fc8fe0
    β€’ Dart version 2.13.3

[βœ“] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    β€’ Android SDK at /Users/paul/Library/Android/sdk
    β€’ Platform android-30, build-tools 28.0.3
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    β€’ Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Xcode 12.5.1, Build version 12E507
    β€’ CocoaPods version 1.10.1

[βœ“] Android Studio (version 4.2)
    β€’ Android Studio at /Applications/Android Studio.app/Contents
    β€’ Flutter plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/9212-flutter
    β€’ Dart plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart
    β€’ Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[βœ“] VS Code (version 1.57.1)
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.23.0

[!] Connected device
    ! No devices available

Migration to null-safety

Starting from Flutter 2.0 and Dart SDK 1.12.0, dart language now supports sound null safety which requires explicitly defining null values.

distinctAttribute in IndexSettings is the wrong type

Description
In IndexSetting the type for distinctAttribute is List<String>?, however MeiliSearch expects a string instead of a list so using this causes an exception.

Expected behavior
No exception when setting the distinct attribute.

Current behavior
An exception is returned when including a distinctAttribute in the settings: MeiliSearchApiError - message: Json deserialize error: invalid type: sequence, expected a string at line 1 column 244 - errorCode: bad_request - errorType: invalid_request_error - errorLink: https://docs.meilisearch.com/errors#bad_request

Environment (please complete the following information):

  • MeiliSearch version: v0.21.0
  • meilisearch-dart version: v0.3.0

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

Update .code-samples.meilisearch.yaml

Related to meilisearch/integration-guides#155

Following the documentation issue (meilisearch/documentation#1290) and PR (meilisearch/documentation#1214) an additional code-sample must be added in the .code-samples.meilisearch.yaml file at the root of the repository.

Information:

Using the following information the code-sample must be created in the repository language.

  • code-sample id: settings_guide_sortable_1
  • index: books
  • route: /settings
  • method: POST
  • content-type: application/json
  • data body:
    {
      "sortableAttributes": [
        "price",
        "author"
      ]
    }

Code Example

In cURL the samples is defined the following way:

curl \
  -X POST 'http://localhost:7700/indexes/books/settings' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "sortableAttributes": [
      "price",
      "author"
    ]
  }'

Please exports PaginatedSearchResult

Description
I want to use meilisearch with pagination but the response was only searchable, that do not contain like totalPage field.

Basic example
I have to import 'package:meilisearch/src/paginated_search_result.dart'; which show warnings.

if (searchResult is PaginatedSearchResult) {
    int? nextPage = (searchResult.totalPages ?? 1) > page ? page++ : null;
    return nextPage;
  }

Make pre-release-tests.yml file

During the pre-release week (concerning only the Meili team, don't bother with the details) I need a CI running against the latest RC of MeiliSearch (and not the latest image). This RC is
Since the CIs of this package run in a Dart container, I don't know how to specify a dynamic variable (get by a script) to define which MeiliSearch version I would like to start.

See the example in the Ruby SDK CI:
https://github.com/meilisearch/meilisearch-ruby/blob/2ce58bdda136c1b672fbbbcdefb41f49a69d85c4/.github/workflows/pre-release-tests.yml#L23-L26

The pre-release-tests.yml file in this package would start the same:

# Testing the code base against the MeiliSearch pre-releases
name: Pre-Release Tests

# Will only run for PRs and pushes to bump-meilisearch-v*
on:
  push:
    branches:
      - bump-meilisearch-v*
  pull_request:
    branches:
      - bump-meilisearch-v*

jobs:
  integration-tests:
    timeout-minutes: 10
    runs-on: ubuntu-latest
    strategy:
      matrix:
        version: ['2.7', '2.8']
    name: integration-tests-against-rc (dart ${{ matrix.version }})
    
   ...

I just currently don't know how to run the latest RC of MeiliSearch in this GitHub Action.

EDIT: Oh maybe use the linux-amd64 assets link to download, unzip and run meilisearch with it: https://github.com/meilisearch/MeiliSearch/releases/download/v0.17.0rc0/meilisearch-macos-amd64

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

code: invalid_api_key on method getDocuments(limit: x) - Version 0.5.3

Description
The method getDocuments(limit: x) doesn't work with meilisearch 0.27.1
However search("", limit: x) as workaround works fine

Expected behavior
Get documents without invalid_api_key error

Current behavior
MeiliSearchApiError - message: The provided API key is invalid. - code: invalid_api_key - type: auth - link: https://docs.meilisearch.com/errors#invalid_api_key

Environment (please complete the following information):

  • Meilisearch version: [0.27.1]
  • meilisearch-dart version: [0.5.3]

Add property indexUid in `Task` class

can you add indexUid property to Task class?. I try to use post man and get Task it return Task and have a property indexUid I want use it but in meilisearch-dart not included the property.

cors error

Description
request to indexes to search

Screenshots or Logs
Access to XMLHttpRequest at 'http://67.205.159.1xx/indexes/dm_bao_gia/search' from origin 'http://localhost:63584' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

configuration server file:

`server {
# END - Enable CORSserver {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;

access_log /var/log/nginx/meilisearch.access.log;
error_log /var/log/nginx/meilisearch.error.log;

location / {
   proxy_pass  http://127.0.0.1:7700;
# START - Enable CORS
proxy_hide_header Access-Control-Allow-Origin;
if ($request_method = 'OPTIONS') {
  add_header 'Access-Control-Max-Age' 1728000;
  add_header "Access-Control-Allow-Origin"  *;
  add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, PUT";
  add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept, >
  return 204;
}

if ($request_method != 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
}

# END - Enable CORS
}

}

`

Environment (please complete the following information):

  • OS: [e.g. Debian GNU/Linux]
  • Meilisearch version: [ v.0.28.1]
  • meilisearch-dart version: [e.g v0.6.0]

Wrong way of sending analytics

Maybe I'm wrong, but the analytics are not sent correctly. That's my bad @brunoocasali, I should have better reviewed your PR! Sorry I don't know how I managed to miss that! πŸ™ˆ

Here:

'User-Agent': Version.qualifiedVersion,

We should send the name of the integration + the number of the version, otherwise we cannot extract correctly the analytics if we do this in every SDK.

According to spec, it should be User-agent: Meilisearch Dart (<integration dart version>)

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

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

Replace MEILISEARCH_HOST by MEILISEARCH_URL in the docker config

⚠️ 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#214


Replace the env var naming from the Dockerfile environment:

  • MEILISEARCH_HOST to MEILISEARCH_URL

Also, look for occurrences inside of the docker-compose.yml file.

After, run the tests according to the instructions in the CONTRIBUTING.md.

Also, check for occurences in the Github Actions workflows and inside of the source code.

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!

Code block in README is not closed properly

Example json response of Custom Search With Filters is not closed properly (missing ```) in README.md, which means rest of the README is incorrectly formatted as part of code block as shown in picture.

image

Update Dio to ^4.0.0

Dio ^3.0.0 is causing lots of dependency issues in my project, as other packages depend on http, which Dio also depends on, and these dependency clashes cannot be resolved. Dio 4.0.0 is stable and null-safe.

I forked this package and have been using it without issue after bumping Dio to ^4.0.0. I'm having a lot of trouble getting docker set up and working on my machine, though, so I haven't been able to run tests and submit a PR.

Can you bump Dio to ^4.0.0? Thanks.

v0.29: Add support to matchingPolicy search request parameter

This improvement motivation is about letting the user customize the behavior of Meilisearch when retrieving documents according to the query words.

  • Add a matchingStrategy parameter to search requests search and searchRaw.
  • The value last is the default strategy if the field is not specified.
  • This field can receive only two valid options last or all.

Expected result:

await client.index('movies').search('shifu', matchingStrategy: 'last');

Good to have: Make the last or all constants where we could quickly use them without mistakes.

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.

Update .code-samples.meilisearch.yaml

Following meilisearch/documentation#1214, we would like to apply some changes in the .code-samples.meilisearch.yaml file at the root of the repository

  • Regarding get_distinct_attribute_1, update_distinct_attribute_1 and reset_distinct_attribute_1: if present, the index name should be shoes
  • Regarding update_distinct_attribute_1: the distinct attribute passed should be skuid and not movie_id

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.