搜索插件、代码仓与 APP 分类

插件详情v1.1.2

algolia

Algolia 是一个纯 Dart SDK,围绕 Algolia REST API 构建,可轻松用于您的 Flutter 或 Dart 项目。

AndroidiOSmacOSWindowsLinux
近 30 天下载
3.1万
喜欢数
228
Pub 分数
120

安装插件

flutter pub add algolia

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Algolia 是一个 Dart SDK,可为 Flutter 和 Dart 应用程序提供与 Algolia 搜索 API 的无缝集成。它通过直观且类型安全的方法封装 Algolia 的 REST API,简化了强大搜索功能的实现。专为寻求快速、可扩展搜索功能的开发者设计,支持全文搜索、分类筛选和跨多个平台的实时结果。该 SDK 支持高效的索引和查询,非常适合需要即时搜索体验的应用程序。支持 Android、iOS、macOS、Windows 和 Linux,确保在各种环境中的性能一致。

适合场景

  • 移动应用中的实时搜索
  • 电子商务中的产品搜索
  • 新闻应用中的内容发现
  • 用户驱动的筛选和分类
  • 索引和查询大型数据集

主要特点

  • 类型安全的 API 包装器
  • 跨平台兼容性
  • 支持分面搜索
  • 实时查询响应
  • 与 Flutter 的轻松集成

适合对象

  • 电子商务应用
  • 内容密集型应用
  • 需要快速搜索的应用程序
  • 使用 Dart/Flutter 的开发者
  • 需要可扩展搜索的项目

使用建议

  • 需要一个 Algolia 账户和 API 密钥
  • 仅限 Algolia 的后端服务
  • 可能需要为复杂查询进行额外设置
  • 依赖网络连接
  • 根据订阅层级应用速率限制

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Hi Team,

I wanted to give you all a heads-up regarding the Dart package I created for Algolia. Going forward, I won’t be able to offer any further support or development for it. If anyone’s interested in forking it or continuing work independently, please feel free—you’re absolutely welcome to.

Right now, my priorities are focused elsewhere, particularly on projects that are part of my paid work. Unfortunately, this package doesn’t fall into that category, so I need to allocate my time accordingly.

Also, it’s worth mentioning that Algolia has since released their own official Dart package. I believe that should be a solid path forward for most use cases. In the past, they had referenced my package in their documentation and even reached out to me directly, promising a small token of appreciation (a welcome kit, as they described). I shared my details with them at the time, but I never received anything—nor was there any follow-up or continued communication.

I even suggested that they consider contributing directly to this project or possibly taking it under their official umbrella, but that conversation didn’t go anywhere. The silence from their side was disheartening, especially given how this package helped fill a gap in their Flutter ecosystem when no official support existed.

I had much more planned for it—like extended diagnostics, an Alogila UI Package (which would be highly configurable), and more flexible integrations. But with no acknowledgment, and with their preference shifting toward native Android/iOS SDKs over the Dart-based approach I took, it doesn’t seem worthwhile to push further without backing.

So, unless something changes, I’ll be stepping away from this package. If you believe there’s still potential or would like to build on it, I’m happy to see others carry it forward.

Thanks for understanding.


Algolia Search (Dart Client)

Algolia

[UNOFFICIAL] Algolia is a pure dart SDK, wrapped around Algolia REST API for easy implementation for your Flutter or Dart projects.

pub package .github/workflows/dart.yml Build Status

Pub - API Docs - GitHub

Features

  • Query / Search / Similar Query
  • Get Object
  • Add Object
  • Add Objects
  • Replace all objects in an Index
  • Update Object
  • Partial Update Object
  • Delete Object
  • Perform Batch Activities
  • Add Index
  • Delete Index
  • Clear Index
  • Copy Index
  • Move Index
  • Index Settings
  • Push Insights Events

Version compatibility

See CHANGELOG for all breaking (and non-breaking) changes.

Become Contributor

If you wish to contribute in our development process, refer to our Contributing Guidelines

Getting started

You should ensure that you add the router as a dependency in your flutter project.

dependencies:
 algolia: ^1.1.2

You should then run flutter packages upgrade or update your packages in IntelliJ.

Example Project

There is a pretty sweet example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

Setting up

  ///
  /// Initiate static Algolia once in your project.
  ///
  class Application {
    static final Algolia algolia = Algolia.init(
      applicationId: 'YOUR_APPLICATION_ID',
      apiKey: 'YOUR_API_KEY',
    );
  }
  
  void main() async {
    ///
    /// Initiate Algolia in your project
    ///
    Algolia algolia = Application.algolia;

    ///
    /// Perform Query
    ///
    AlgoliaQuery query = algolia.instance.index('contacts').query('john');

    // Perform multiple facetFilters
    query = query.facetFilter('status:published');
    query = query.facetFilter('isDelete:false');

    // Get Result/Objects
    AlgoliaQuerySnapshot snap = await query.getObjects();

    // Checking if has [AlgoliaQuerySnapshot]
    print('Hits count: ${snap.nbHits}');

    ///
    /// Perform Index Settings
    ///
    AlgoliaIndexSettings settingsRef = algolia.instance.index('contact').settings;

    // Get Settings
    Map<String, dynamic> currentSettings = await settingsRef.getSettings();

    // Checking if has [Map]
    print('\n\n');
    print(currentSettings);

    // Set Settings
    AlgoliaSettings settingsData = settingsRef;
    settingsData = settingsData.setReplicas(const ['index_copy_1', 'index_copy_2']);
    AlgoliaTask setSettings = await settingsData.setSettings();

    // Checking if has [AlgoliaTask]
    print('\n\n');
    print(setSettings.data);

    // Pushing Event
    AlgoliaEvent event = AlgoliaEvent(
      eventType: AlgoliaEventType.view,
      eventName: 'View contact',
      index: 'contacts',
      userToken: 'user123',
    );
    await algolia.instance.pushEvents([event]);
  }

Insights

The Insights API lets you push a collection of events related to how your product is being used. Sending those events is a required step for using several Algolia features like Click analytics, A/B Testing, Personalization and Dynamic Re-Ranking.

  • .pushEvents(List<AlgoliaEvent> events)

Search Parameters

Here is the list of parameters you can use with the search method (search scope). We have managed to include most commonly used parameters for search functionality and there many more to be added in future releases.

We have indicated counts of queryable parameters with their availability status on official Algolia website and what we have managed to support it in this version of the release.

search (1/1)
  • .query(String value)
  • .similarQuery(String value)
attributes (2/2)
  • .setAttributesToRetrieve(List<String> value)
  • .setRestrictSearchableAttributes(List<String> value)
filtering (6/6)
  • .filters(String value)
  • .facetFilter(dynamic value) This can be used multiple times in a query.
  • .setOptionalFilter(String value) This can be used multiple times in a query.
  • .setNumericFilter(String value) This can be used multiple times in a query.
  • .setTagFilter(String value) This can be used multiple times in a query.
  • .setSumOrFiltersScore(bool value)
faceting (4/4)
  • .setFacets(List<String> value)
  • .setMaxValuesPerFacet(int value)
  • .setFacetingAfterDistinct({bool enable = true})
  • .setSortFacetValuesBy(AlgoliaSortFacetValuesBy value)
highlighting-snippeting (6/6)
  • .setAttributesToHighlight(List<String> value)
  • .setAttributesToSnippet(List<String> value)
  • .setHighlightPreTag(String value)
  • .setHighlightPostTag(String value)
  • .setSnippetEllipsisText(String value)
  • .setRestrictHighlightAndSnippetArrays({bool enable = true})
pagination (4/4)
  • .setPage(int value)
  • .setHitsPerPage(int value)
  • .setOffset(int value)
  • .setLength(int value)
typos (5/5)
  • .setMinWordSizeFor1Typo(int value)
  • .setMinWordSizeFor2Typos(int value)
  • .setTypoTolerance(dynamic value)
  • .setAllowTyposOnNumericTokens(bool value)
  • .setDisableTypoToleranceOnAttributes(List<String> value)
geo-search (7/7)
  • .setAroundLatLng(String value)
  • .setAroundLatLngViaIP(bool value)
  • .setAroundRadius(dynamic value)
  • .setAroundPrecision(int value)
  • .setMinimumAroundRadius(int value)
  • .setInsideBoundingBox(List<BoundingBox> value)
  • .setInsidePolygon(List<BoundingPolygonBox> value)
languages (8/11)
  • .setIgnorePlurals(dynamic value)
  • .setRemoveStopWords(dynamic value)
  • .setCamelCaseAttributes(List<String> value)
  • .setDecompoundedAttributes(dynamic value)
  • .setkeepDiacriticsOnCharacters(String value)
  • .setQueryLanguages(List<String> value)
  • .setIndexLanguages(List<String> value)
  • .setNaturalLanguages(List<String> value)
query-rules (3/3)
  • .setEnableRules({bool enabled = false})
  • .setFilterPromotes({bool enabled = false})
  • .setRuleContexts(List<String> value)
personalization (3/3)
  • .setEnablePersonalization({bool enabled = false})
  • .setPersonalizationImpact({required int value})
  • .setUserToken({required String value})
query-strategy (7/7)
  • .setQueryType(QueryType value)
  • .setRemoveWordsIfNoResults(RemoveWordsIfNoResults value)
  • .setAdvancedSyntax({bool enabled = false})
  • .setOptionalWords(List<String> value)
  • .setDisablePrefixOnAttributes(List<String> value)
  • .setDisableExactOnAttributes(List<String> value)
  • .setExactOnSingleWordQuery(ExactOnSingleWordQuery value)
performance (2/2)
  • .setNumericAttributesForFiltering({required List<String> value})
  • .setAllowCompressionOfIntegerArray({bool enabled = false})
advanced (11/15)
  • .setAttributeForDistinct(String value)
  • .setDistinct({dynamic value = 0})
  • .setGetRankingInfo({bool enabled = true})
  • .setClickAnalytics({bool enabled = false})
  • .setAnalytics({bool enabled = false})
  • .setAnalyticsTags(List<String> value)
  • .setSynonyms({bool enabled = false})
  • .setReplaceSynonymsInHighlight({bool enabled = false})
  • .setMaxFacetHits(int value)
  • .setPercentileComputation({bool enabled = false})
  • .setEnableABTest({bool enabled = false})
custom-query (11/15)
  • .custom(String key, dynamic value)
GET RESULT
  • .getObjects()

Settings Parameters

Here is the list of parameters you can use with the settings method (settings scope). We have managed to include most commonly used parameters for settings functionality and there many more to be added in future releases.

We have indicated counts of settings parameters with their availability status on official Algolia website and what we have managed to support it in this version of the release.

attributes (4/4)
  • .setSearchableAttributes(List<String> value)
  • .setAttributesForFaceting(List<String> value)
  • .setUnretrievableAttributes(List<String> value)
  • .setAttributesToRetrieve(List<String> value)
ranking (3/3)
  • .setRanking(List<String> value)
  • .setCustomRanking(List<String> value)
  • .setReplicas(List<String> value)
faceting (2/2)
  • .setMaxValuesPerFacet(int value)
  • .setSortFacetValuesBy(AlgoliaSortFacetValuesBy value)
highlighting-snippeting (6/6)
  • .setAttributesToHighlight(List<String> value)
  • .setAttributesToSnippet(List<String> value)
  • .setHighlightPreTag(String value)
  • .setHighlightPostTag(String value)
  • .setSnippetEllipsisText(String value)
  • .setRestrictHighlightAndSnippetArrays({bool enable = true})
pagination (2/2)
  • .setHitsPerPage(int value)
  • .setPaginationLimitedTo(int value)
typos (7/7)
  • .setMinWordSizeFor1Typo(int value)
  • .setMinWordSizeFor2Typos(int value)
  • .setTypoTolerance(dynamic value)
  • .setAllowTyposOnNumericTokens(bool value)
  • .setDisableTypoToleranceOnAttributes(List<String> value)
  • .setDisableTypoToleranceOnWords(List<String> value)
  • .setSeparatorsToIndex(List<String> value)
languages (8/11)
  • .setIgnorePlurals(dynamic value)
  • .setRemoveStopWords(dynamic value)
  • .setCamelCaseAttributes(List<String> value)
  • .setDecompoundedAttributes(dynamic value)
  • .setkeepDiacriticsOnCharacters(String value)
  • .setQueryLanguages(List<String> value)
  • .setIndexLanguages(List<String> value)
  • .setNaturalLanguages(List<String> value)
query-rules (3/3)
  • .setEnableRules({bool enabled = false})
  • .setFilterPromotes({bool enabled = false})
  • .setRuleContexts(List<String> value)
personalization (3/3)
  • .setEnablePersonalization({bool enabled = false})
  • .setPersonalizationImpact({required int value})
  • .setUserToken({required String value})
query-strategy (7/7)
  • .setQueryType(QueryType value)
  • .setRemoveWordsIfNoResults(RemoveWordsIfNoResults value)
  • .setAdvancedSyntax({bool enabled = false})
  • .setOptionalWords(List<String> value)
  • .setDisablePrefixOnAttributes(List<String> value)
  • .setDisableExactOnAttributes(List<String> value)
  • .setExactOnSingleWordQuery(ExactOnSingleWordQuery value)
performance (2/2)
  • .setNumericAttributesForFiltering({required List<String> value})
  • .setAllowCompressionOfIntegerArray({bool enabled = false})
advanced (11/15)
  • .setAttributeForDistinct(String value)
  • .setDistinct({dynamic value = 0})
  • .setGetRankingInfo({bool enabled = true})
  • .setClickAnalytics({bool enabled = false})
  • .setAnalytics({bool enabled = false})
  • .setAnalyticsTags(List<String> value)
  • .setSynonyms({bool enabled = false})
  • .setReplaceSynonymsInHighlight({bool enabled = false})
  • .setMaxFacetHits(int value)
  • .setPercentileComputation({bool enabled = false})
  • .setEnableABTest({bool enabled = false})
GET Settings
  • .getSettings()
SET Settings
  • .setSettings()

Algolia [Unofficial SDK for Dart] is a Knoxpo original.

所属分类

依赖

依赖清单 4 项

源码仓库

使用此插件的项目