Dart client for Typesense

Overview

Typesense pub package CircleCI codecov pub points

Dart client library for accessing the HTTP API of Typesense search engine.

Note: This package is still under development. Version 0.2.0 will be fully migrated to null safety; related issue. Some existing APIs might change or new APIs might be available in the future.

Installation

Add typesense as a dependency in your pubspec.yaml file.

dependencies:
  typesense: ^0.1.1

Usage

Read the documentation here: https://typesense.org/docs/api/

Tests are also a good place to know how the library works internally: test

Note: When using this library in a user-facing app, please be sure to use an API Key that only allows search operations instead of the master API key. See keys.dart for an example of how to generate a search only API key.

See Configuration class for a list of all client configuration options.

Examples

The examples that walk you through on how to use the client: main.dart

Make sure to README beforehand.

Compatibility

Typesense Server typesense-dart
>= v0.21.0 >= v0.1.1

Contributing

Visit CONTRIBUTING.md

Credits

This library is authored and maintained by our awesome community of contributors:

Comments
  • ext-firestore-typesense-search-indexToTypesenseOnFirestoreWrite: Request failed with HTTP code 404 | Server said: Not Found

    ext-firestore-typesense-search-indexToTypesenseOnFirestoreWrite: Request failed with HTTP code 404 | Server said: Not Found

    Hey, I have installed the extension and using the official Typesense cloud to host but I am getting this error from the firebase cloud function when creating new documents:

    Flutter Web/ Dart code:

    @override
    void initState() {
      const host1 = "wt62ejrukzvh378pp-1.a1.typesense.net";
      const host2 = "wt62ejrukzvh378pp-2.a1.typesense.net";
      const host3 = "wt62ejrukzvh378pp-3.a1.typesense.net";
      const protocol = Protocol.http;
      final config = Configuration(
        // Replace with your configuration
        '[admin key (removed on github for security reasons)]',
        nodes: {
          Node(
            protocol,
            host1,
            port: 443,
          ),
          Node(
             protocol,
            host2,
            port: 443,
          ),
          Node(
            protocol,
            host3,
            port: 443,
          ),
        },
        numRetries: 3, // A total of 4 tries (1 original try + 3 retries)
        connectionTimeout: const Duration(seconds: 10),
      );
      client = Client(config);
    
      super.initState();
    }
    

    Below are the screenshots for the extension configuration and firebase functions log:

    WhatsApp Image 2022-03-13 at 12 09 24 WhatsApp Image 2022-03-13 at 12 11 25

    bug 
    opened by rdcoder33 17
  • Implementing ApiCall class

    Implementing ApiCall class

    As far as I've understood from gazing at the implementation in JavaScript and Python, here are the requirements summed up:

    The main function is the make_request or equivalent. It's responsible for connecting with a node and completing the request. If a nearestNode is present in the Configuration, it'll try to connect to it given it's healthy, if not it'll fall back to the nodes and use them in a round-robin fashion.

    I'm not sure how if a node is healthy is tracked? What I think: Every node starts with their health status as "fine" and when eventually if a request fails, that node is marked unhealthy and the next node is tried until eventually due to round-robin this node is considered again, and if the request is successful this time, it's again marked healthy again? Also, is this where numRetries comes into play? In that, if a node fails to respond, we would try the same node numRetries times?

    I'm also not sure about healthcheckInterval present in the Configuration class. What's its use?

    enhancement 
    opened by happy-san 12
  • Valid `x-typesense-api-key` header must be sent

    Valid `x-typesense-api-key` header must be sent

    Describe the bug

    It seems the Configuration object is not setting the API key. Basic configuration:

    class SearchService {
    Client? client;
    String searchOne = "add-endpoint-here";
    String searchTwo = "add-endpoint-here";
    String searchThree = "add-endpoint-here";
    
    void initialize(String searchKey) {
        var config = Configuration(
          searchKey,
          nodes: {
            Node(Protocol.https, searchOne, port: 443),
            Node(Protocol.https, searchTwo, port: 443),
            Node(Protocol.https, searchThree, port: 443),
            },
          connectionTimeout: Duration(seconds: 2),
          );
          client = Client(config);
       }
    
      Future<dynamic> Search(
        String? value,
        String queryBy,
        String collection,
      ) async {
        try {
          var search = await client!.collection(collection).documents.search({
            "q": value ?? "*",
            "query_by": queryBy,
          });
             return search;
            } catch(err){
              return err;
            }
        }
    }
    

    Related: Typesense Error 476

    Steps to reproduce the behavior:

    1. Initialize client - No issues
    2. Search/retrieve documents - Error

    Expected behavior

    1 . Return either collections or documents.

    Additional context

    • Using a shell to query/retrieve any document doesn't cause any issue.
    • Using Admin-Key, Search-only-Key, and Scoped-Key cause the same errors.
    • Using client SDK:

    Error 1

    401: {"message": "Forbidden - a valid `x-typesense-api-key` header must be sent."}
    

    Error 2 This error is also a weird behavior from the client SDK. All schema variables are defined with type and facet. If the client is not throwing Error 1, it's giving this other error:

    400: {"message": "Field `value` should be a string or a string array."}
    

    "value" variable config (Schema):

    ...
        {
          "facet": false,
          "index": true,
          "name": "value",
          "optional": false,
          "type": "float"
        },
    ...
    

    Note: Setting the "sendApiKeyAsQueryParam" variable won't change the outcome.

    bug 
    opened by elhe26 9
  • Move codebase to non-nullablity

    Move codebase to non-nullablity

    Description

    According to the docs

    You can — and should — migrate your package before packages that depend on it are migrated. Your null-safe package is usable by packages and apps that don’t use null safety yet, as long as they use Dart 2.12 or later. For example, the Dart and Flutter core libraries are null safe, and they’re still usable by apps that haven’t migrated to null safety.

    Since it's encouraged to be in Dart 2.12 or later, we'll update the dart client.

    enhancement good first issue 
    opened by happy-san 5
  • Add ability to specify locale when creating a schema

    Add ability to specify locale when creating a schema

    I can assign a locale to a schema field using the API directly, like this

    	 curl "http://localhost:8108/collections" \
           -X POST \
           -H "Content-Type: application/json" \
           -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
           -d '{
             "name": "english_thai",
             "fields": [
              {"name": "english", "type": "string" },
              {"name": "thai", "type": "string", "locale": "th" }
             ],
             "default_sorting_field": "num_employees"
           }'
    

    I can't find an equivalent way to specify locale using the dart client.

    enhancement 
    opened by keith555 4
  • simple search

    simple search

    Can you please explain how I can make a simple search on one of my collections? I followed the typesense tutorials but I can't get anything to work with your package. Thanks

    enhancement 
    opened by kiloki-official 2
  • Support geopoint type for Typesense 0.21

    Support geopoint type for Typesense 0.21

    Thank you very much @happy-san for the amazing work on the Dart client.

    Is your feature request related to a problem? Please describe.

    Typesense 0.21 introduces geo search so you can index and search on lat/long fields. A new type geopoint is introduced for this purpose.

    Please see usage here: https://gist.github.com/kishorenc/1f537c728f89960048272a03d36bad01

    Describe the solution you'd like

    • [x] #91

    • [x] #92

    enhancement good first issue 
    opened by kishorenc 1
  • Support for collection update

    Support for collection update

    Is your feature request related to a problem? Please describe.

    In the next version of Typesense (0.23) we're supporting in-place schema changes to collections through a PATCH /collections/:name end-point. We need to add this method to the client.

    Describe the solution you'd like

    Please see the examples I've created for the various clients (not all of them are implemented yet) here.

    The Dart version looks like this:

    final updateSchema = UpdateSchema(
      {
        Field('company_category', Type.string),
        Field('num_employees', drop: true)
      }
    );
    await client.collection('companies').update(updateSchema);
    

    For now you can change only the fields (can't change the name or other properties like default_sorting_field etc. yet). So we need a UpdateSchema wrapper class that's a subset of the Schema class (only containing fields) with which we can call the .update().

    cc @happy-san

    enhancement 
    opened by kishorenc 0
  • Add more models

    Add more models

    Is your feature request related to a problem? Please describe.

    I miss the known type safety by missing models for SearchParameters and SearchResponse, a map is always not as easy to use and more error prone than a model.

    Describe the solution you'd like

    Add the models for SearchParameters and SearchResponse.

    enhancement 
    opened by guenth39 2
  • Implement `Least Recently Used` eviction in `RequestCache` .

    Implement `Least Recently Used` eviction in `RequestCache` .

    Is your feature request related to a problem? Please describe.

    _cachedResponses doesn't have a limit on the number of _Cache's it can store and the expired _Cache is conditionally deleted, so a memory leak occurs.

    Describe the solution you'd like

    Implement an LRU algorithm.

    Additional context

    related issue

    enhancement good first issue 
    opened by happy-san 5
  • Get the `codecov` badge working.

    Get the `codecov` badge working.

    Is your feature request related to a problem? Please describe.

    Currently, the codecov badge in README isn't connected to CI and shows Unknown status

    Describe the solution you'd like

    Get it working by integrating uploading coverage reports in the CircleCi workflow.

    Describe alternatives you've considered

    Well many, just couldn't get it working.

    Additional context

    enhancement help wanted 
    opened by happy-san 0
Releases(0.3.0)
Owner
Typesense
Fast, typo tolerant search engine for building delightful search experiences.
Typesense
A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.

GraphQL Flutter ?? Bulletin See the v3 -> v4 Migration Guide if you're still on v3. Maintenance status: Low. Follow #762 for updates on the planned ar

Zino & Co. 3.1k Jan 5, 2023
Vrchat mobile client - VRChat Unofficial Mobile Client For Flutter

VRChatMC VRChatの非公式なAPIを利用したVRChatのモバイルクライアント Flutterで作成されたシンプルなUIが特徴的です iosビルドは

ふぁ 8 Sep 28, 2022
Mysql.dart - MySQL client for Dart written in Dart

Native MySQL client written in Dart for Dart See example directory for examples

null 48 Dec 29, 2022
A Dart client for the NATS messaging system. Design to use with Dart and Flutter.

Dart-NATS A Dart client for the NATS messaging system. Design to use with Dart and flutter. Flutter Web Support by WebSocket client.connect(Uri.parse(

Chart Chongcharoen 32 Nov 18, 2022
Socketio dart server and client - Full Socket.io implementation using Dart Lang

Getting Started Step 1: Run dart_server.dart Step 2: Android Emulator has proble

Trần Thiên Trọng 1 Jan 23, 2022
Dart client library to interact with Supabase Storage

storage-dart Dart client library to interact with Supabase Storage. Contributing Fork the repo on GitHub Clone the project to your own machine Commit

Supabase 22 Dec 14, 2022
Pure Dart Client for Nakama Server 🌟🥰🤩

Nakama Flutter Client ?? ?? ?? ?? Nakama is an open-source scalable game server. This is a Flutter client for Nakama written in pure dart and supports

Oliver Brunsmann 57 Dec 6, 2022
A streaming client for the Komga self-hosted comics/manga/BD server targeting Android/iOS written in Dart/Flutter

Klutter A streaming client for the Komga self-hosted comics/manga/BD server targeting Android/iOS written in Dart/Flutter Background This is a project

Mark Winckle 58 Dec 7, 2022
A powerful Http client for Dart, which supports Interceptors, FormData, Request Cancellation, File Downloading, Timeout etc.

dio_http A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout

null 46 Dec 19, 2021
Dart API Client which wraps the QvaPay API

qvapay_api_client Dart API Client which wraps the QvaPay API The client needs Dio to perform the requests, you must inject an instance in the construc

QvaPay 7 Nov 2, 2022
a project-m36 websocket client written by flutter/dart

project_m36_websocket_client A Flutter web websocket client for Project-M36. It's also an attempt to bring algebraic datatypes into the Dart land. Pro

null 1 Jan 8, 2022
A powerful Http client for Dart, which supports Interceptors, FormData, Request Cancellation, File Downloading, Timeout etc.

Language: English | 中文简体 dio A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File

Flutter中国开源项目 11.2k Jan 3, 2023
Unsplash Client App written using dart and flutter. (Work in progress)

Upsplash Unofficial Unsplash client written using dart and flutter Sreenshots Architecture The goal of this pattern is to make it easy to separate pre

Arslan 25 Sep 1, 2022
A simple and robust dart FTP Client Library to interact with FTP Servers with possibility of zip and unzip files.

Flutter FTP Connect Flutter simple and robust dart FTP Connect Library to interact with FTP Servers with possibility of zip and unzip files. Key Featu

Salim Lachdhaf 49 Dec 13, 2022
A Dart client for FusionAuth, Flutter compatible

FusionAuth Dart Client If you're integrating FusionAuth with a Dart or Flutter application, this library will speed up your development time. For addi

FusionAuth 9 Dec 14, 2022
A wrapper around our Cocoa and Java client library SDKs, providing iOS and Android support for those using Flutter and Dart.

Ably Flutter Plugin A Flutter plugin wrapping the ably-cocoa (iOS) and ably-java (Android) client library SDKs for Ably, the platform that powers sync

Ably Realtime - our client library SDKs and libraries 46 Dec 13, 2022
A WordPress API client for dart with support for WooCommerce and custom namespaces.

WordPress REST API client for Dart | Flutter Description A WordPress REST API client for dart with support for WooCommerce and custom namespaces/endpo

DHM Group 73 Nov 26, 2022
A Dart client for Supabase

supabase-dart A Dart client for Supabase. What is Supabase Supabase is an open source Firebase alternative. We are a service to: listen to database ch

Supabase Community 392 Jan 7, 2023
An Imgur API Client Library that uses Imgur's v3 API for Dart

imgur.dart An Imgur API Client Library that uses Imgur's v3 API for Dart. Usage

null 2 Dec 2, 2022