搜尋套件、儲存庫與 APP 分類

套件詳情v0.19.0

meilisearch

Meilisearch Dart 是 Dart 與 Flutter 開發人員的 Meilisearch API 客戶端。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
4240
喜歡數
65
Pub 分數
140

安裝套件

flutter pub add meilisearch

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Meilisearch Dart 是一個輕量級的 API 客戶端,適用於 Dart 和 Flutter 應用程式,可實現與 Meilisearch(一種快速、相關且可自訂的搜尋引擎)的無縫整合。它允許開發者在應用程式中直接執行即時搜尋、管理索引和處理文件更新。該客戶端支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,非常適合跨平台搜尋功能。透過直覺的方法和最少的設定,它簡化了為任何 Flutter 專案新增強大搜尋功能的過程。

適用情境

  • 移動應用中的即時搜尋
  • Flutter 中的索引管理
  • 跨多個平台的全文搜尋
  • 搜尋建議和自動完成
  • 文件索引和更新
  • 跨平台搜尋實作

主要特色

  • 搜尋操作的簡單 API
  • 支援所有主要平台
  • 即時搜尋結果
  • 輕鬆的索引和文件處理
  • 輕便且快速
  • 內建錯誤處理

適合對象

  • 需要搜尋功能的Flutter開發人員
  • 需要快速全文搜尋的應用
  • 針對多個平台的專案
  • 使用 Meilisearch 後端的團隊
  • 希望實現低延遲搜尋的開發者

使用建議

  • 需要一個正在運行的 Meilisearch 伺服器
  • 需要適當的 API 金鑰管理
  • 僅限 Meilisearch 後端
  • 搜尋查詢的網路依賴
  • 不適用於僅離線搜尋

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Meilisearch

Meilisearch Dart

Meilisearch | Meilisearch Cloud | Documentation | Discord | Roadmap | Website | FAQ

Pub Version GitHub Workflow Status License 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.

🔧 Installation

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

dependencies:
  meilisearch: ^0.19.0

Then open your terminal and update dart packages.

pub get
Run Meilisearch

⚡️ Launch, scale, and streamline in minutes with Meilisearch Cloud—no maintenance, no commitment, cancel anytime. Try it free now.

🪨 Prefer to self-host? Download and deploy our fast, open-source search engine on your own infrastructure.

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

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

所屬分類

依賴

依賴清單 5 項

原始碼儲存庫

使用此套件的專案