Git Product home page Git Product logo

dart_algolia's Introduction

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.

dart_algolia's People

Contributors

aallam avatar aemelyanovff avatar creativecreatorormaybenot avatar nhathiwala avatar timtraversy avatar vladislavfitz 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  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

dart_algolia's Issues

getObjects fails on specific index because of null-safety

Dart version: [eg: 2.12.0]
Flutter version: [eg: 2.0.0 (stable)]

Creating a query and then calling getObjects() would throw a null-safety exception with one of two algolia apps.

This is due to the index returning less data than expected for example:
"nbHits" was missing, but this package was expecting it and therefore throwing an error.

Another index returned the missing params with the same query. So the different responses are probably caused by the configurations of the algolia apps in the backend. Sadly I can not check why the API responses were different, because I do not have access to the two apps anymore.

Problem in the catch block of query.getObjects()

Dart version: [2.4.0]
Flutter version: [1.7.8+hotfix.3 (stable)]
Algolia Dart Client version : [0.1.6+1]

Describe the bug
I think there is a problem with the error handling of the function getObjects(). It returns the catched error, which is creating an other exception : 'type 'SocketException' is not a subtype of type 'FutureOr<AlgoliaQuerySnapshot>', as it is trying to cast the error (SocketExcpetion here) into the return type (Future<AlgoliaQuerySnapshot>). My guess is that it would be better to rethrow the error or handling the errors properly.

To Reproduce
Try calling getObjects on a query with no internet connection on the device.

Expected behavior
Throw typed Exceptions, in order to be able to catch the exception with

try {
      AlgoliaQuerySnapshot snap = await query.getObjects();
} on SocketException catch(e) {
      print(e)
      // Error handling
}

Missing queryID implementation

Dart version: [eg: 2.12.0]
Flutter version: [eg: 2.0.6 (stable)]

Describe the bug
When we create a query, for example

    AlgoliaQuery query = PopAlgolia.ref.instance
        .index('someIndex')
        .setEnablePersonalization(enabled: true)
        .setClickAnalytics(enabled: true)
        .setUserToken(_mainUser.userId)
        .query(request)
        .setPage(_algoliaPage.value)
        .setHitsPerPage(20);

algolia returns queryID: c24b3c3fc3701f1d09c5a8da968ee496, parameter with snapshot, that is required for personalisation.

Can you please add the property with this parameter?

Right now in the log, I can see in the content of the snapshot

long text with data....
queryID: b7ebe1246bebbe59fb6f45e7c73a3363, processingTimeMS: 1}

Hits per page not working (throwing error) for multiple queries

Dart version: [eg: 2.12.0]
Flutter version: [eg: 2.0.0 (stable)]

Describe the bug
Hits per page for multiple queries is not working.
Getting type 'int' is not a subtype of type 'Iterable' error instead.

Its working fine for single queries.

To Reproduce
Steps to reproduce the behavior:
For reproduce purpose, can use one query.

  1. Create query.

    AlgoliaQuery firstQuery = algolia.instance
    .index('someIndex')
    .setHitsPerPage(5)
    .query(search);

  2. Call get objects

    List snap = await algolia.multipleQueries
    .addQueries([firstQuery]).getObjects();

Expected behavior
Should be works fine like single query

can't pass List<dynamic> to setFacetFilter

Dart version: 2.7.0
Flutter version: 1.12.13

Expected behavior
setFacetFilter can receive List<dynamic>

/// - `[["category:Book", "category:Movie"], "author:John Doe"]` translates as `(category:Book OR category:Movie) AND author:"John Doe"`.

Actual behavior
setFacetFilter can only receive List<String> or String

assert(value is String || value is List<String>,

Debug Mode - Logs

Currently the code does the requests and return the responses

Expected

Somehow enable a debug mode to print in console all requests request with headers and response.

This is very useful to know what is happening when something goes wrong

Algolia compatibility issue with firebase ^5.0.2

I am trying to use algolia dart package to my angular dart application and I have encountering compatibility issues with firebase ^5.0.2 because it uses/depends on http ^0.11.3 and algolia depends on http ^0.12.0.

Can algolia be forced or modified to also use http ^0.11.3 to http ^0.12.0.

Empty search queries should be allowed

In query.dart it is specified that

"If the text is empty or absent, the search will match every object in your index."

Further the library prevents an empty query string. This directly falls against Algolia's pinned suggestion returns which allows you to pin items to return when an empty search is provided.

I don't believe restricting the query to non empty string is the right functionality.

setData() fails with Path not supported by Algolia REST API

Dart version: 2.12.3
Flutter version: 2.0.6 (stable)

setData() fails and gives the error message : "Path not supported by Algolia REST API. Please have a look at http://www.algolia.com/doc/rest_api for the list of valid commands, status: 404"

Future<void> updateName(String id, String name) async { var index = algoliaUserNames.instance.index('UserNames'); try { await index.object(id).setData({'name': name}); } catch (e) { print(e.error); } }
If replacing setData() by updateData() on an existing object, it works fine.
setData fails whether the object exists or not.
I tried with a custom API key where the "addObject" ACL had been added, and I also tried with the Admin API key, without success.

Steps to reproduce the behavior:
Try using setData().

Can't get queryID

Flutter version: 2.5.3 (stable)

When I'm trying to get a queryId from QuerySnapshot I'm getting this error:

Error: [+5335 ms] flutter: type 'Null' is not a subtype of type 'String'

Future<List<AlgoliaObjectSnapshot>> _operation(String input) async { AlgoliaQuery query = algolia.instance.index("job").query(input); AlgoliaQuerySnapshot querySnap = await query.getObjects(); List<AlgoliaObjectSnapshot> results = querySnap.hits; try { print(querySnap.queryId); } catch (ex) { print(ex); } return results; }
Zrzut ekranu 2021-11-11 o 17 31 38

Space in facet value breaks request

Hey when there is a space in a facet value the network request fails

algolia.instance
        .index('NewsAndEventsIndex')
        .setHitsPerPage(HITS_PER_PAGE)
        .query(query)
        .filters('Type:Important dates');

on the request is

{"facetFilters":[],
"optionalFilters":[],
"numericFilters":[],
"tagFilters":[],
"hitsPerPage":10,
"query":"",
"filters":"Type: Important dates"}

this is the response

{
  "message": "filters: Unexpected token string(dates) expected end of filter at col 15",
  "status": 400
}

Unable to search in release apk.

Flutter= 2.2.2
Dart= 2.13.3

In debug mode I can search words and it compares correctly with indexes. But in release mode, when I search something it's showing nothing. I am using search member function of algolia function.

  • Device: Android
  • OS: 11

NoSuchMethodError when calling getObjects() on zero results.

Flutter version: 1.16.3

Describe the bug
When calling getObjects on AlgoliaQuerySnapshot will throw NoSuchMethod error if the query is empty.

E/flutter (32206): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The method 'map' was called on null.
E/flutter (32206): Receiver: null
E/flutter (32206): Tried calling: map<AlgoliaObjectSnapshot>(Closure: (dynamic) => AlgoliaObjectSnapshot)
E/flutter (32206): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (32206): #1      new AlgoliaQuerySnapshot.fromMap (package:algolia/src/query_snapshot.dart:36:10)
E/flutter (32206): #2      AlgoliaQuery.getObjects (package:algolia/src/query.dart:77:33)

Expected behavior
Null or an empty array should be returned.

Null safety

Since Null Safety is in beta, it is time to update Dart Algolia library to support null safety. Are there any timelines on this? Thanks!

Query getObjects does not Report When an API Key does not have acess to an Index

Dart version: 2.9.0-21.0.dev
Flutter version: 1.21.0-2.0.pre.66

Description

I used an API key which apparently was not compatible with the index I was trying to query.
However, the client only threw the following error: NoSuchMethodError: invalid member on null: 'map'

This means that it took a while to figure out that I had to get a new API key for the query.

client.instance.index('index').search('').getObjects()

Searching in facet values

Is your feature request related to a problem? Please describe.
It seems like the searchForFaceValues method is not supported. Having this is very important for me as I need to implement tags autocompletion.

Describe the solution you'd like
Right now the query method performs the search only over the record objects. Perhaps another method is needed, something like queryFacets that would allow for the facet filtering.

Describe alternatives you've considered
I've tried using setFacets method, but it retrieves all the values, which will be thousands. I only need a few tags that start with a text I want to perform a search with.

[Feature]convert string for debug

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

    const algolia = AlgoliaService.algolia;
    final query = algolia.instance.index('hoge');

    final query = _getQuery()
        .setFilters(
          'a=1',
        )
        .setFacetFilter("[["category:Book", "category:Movie"], "author:John Doe"]")

later, I want to convert to query string.

print(query.queryString());

just query.toString(); is
I/flutter (12300): Instance of 'AlgoliaQuery'

Describe the solution you'd like
print query string.

Describe alternatives you've considered
add queryString() feature.

Additional context
N/A

How to use a securedAPIkey?

Hi,

Do you have an example of how to dynamically set the apiKey to use when initializing the Algolia client? I can set it up with my default 'out-of-the-box' search key no problem:

class AlgoliaApp {

  static final Algolia algolia = Algolia.init(
    applicationId: 'myAppId',
    apiKey: 'myKey', <-- static key from the Algolia dashboard
  );
}

But I need to use secure keys which are generated dynamically from my app's back end server, so that I can restrict search access based on criteria about the user. The docs don't have an example of how to do this (as far as I can see).

If I try to pass in the apiKey as a a parameter to the constructor of the class above, something like this:

class AlgoliaApp {
  final String userToken;
  AlgoliaApp(this.userToken);

  static final Algolia algolia = Algolia.init(
    applicationId: 'myAppId',
    apiKey: userToken,
  );
}

I get a compiler error saying:

The instance member 'userToken' can't be accessed in an initializer

Definitely not a bug, just a question/request for help. Any advice much appreciated. Thought better to post here rather than on SO as it's specific to this package rather than flutter/dart etc.

Thanks,

Multiples queries search

Is your feature request related to a problem? Please describe.
No problem related, nice package!
Describe the solution you'd like
Implement the multiples indexes search supported by Algolia
Describe alternatives you've considered
I have to search in 3 differents indices, I would likes to not invoke 3 difference search request in order to get my result :).
Additional context
Additional info :
https://www.algolia.com/doc/api-reference/api-methods/multiple-queries/?language=javascript

Handle dynamic highlight fields

Crashes when _highlightResult contains other field types.

Error is coming from object_snapshot.dart -> AlgoliaObjectSnapshot.fromMap when parsing map._highlightResult

Error: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>'

No object returned in Flutter Web Release

Dart version: [ eg: 2.14.2 ]
Flutter version: [ eg: 2.5.1 ]

Bug Description
Flutter web release mode always errors out instead of returning an Algolia snapshot.
I have a fix at the bottom. It should at least help point in the right direction.

This is only in release mode and not debug mode. An error is printed to the browser console:
NoSuchMethodError: method not found: 'h' on null
(Note that flutter web will replace method names so 'h' doesn't really mean anything.)

Reproduction
Steps to reproduce the behavior:

  1. Setup an Algolia index
  2. Build any flutter project for web (in release mode).
  3. Try to query any objects from Algolia.

Expected behavior
When query() is called, then an Algolia snapshot is returned with correct hits.

Desktop (please complete the following information):

  • Browser [chrome]
    This bug only appears in release mode. It does not happen in debug mode.

Additional context / Fix
I was able to fix the issue by replacing
lib/src/algolia.dart: line 111

    return response;

Right now it is:

    return json.decode(response.body);

I'm pretty sure that the return type should be http.Response, however json.decode is returning dynamic. I'm not 100% sure why it works in debug mode and not release, or why this fixes it.
Please let me know if you need any more info.

Error with partialUpdateObject

Dart version: 2.13.3
Flutter version: 2.2.2

Describe the bug
When using partialUpdateObject I receive the following error:
{message: Path not supported by Algolia REST API. Please have a look at http://www.algolia.com/doc/rest_api for the list of valid commands, status: 404}

Additional context
The library is sending a PUT request to partially update an object. But according to the link in the error, it should be a POST.

Filters are not being added to query

Dart version: 2.2.0
dart_algolia version: 0.1.4+3

Describe the bug
Filters are not being added to query.

To Reproduce

final AlgoliaQuery _algQuery = algolia.instance.index('index');
_algQuery.setFacetFilter('test:10732');
print(_algQuery.parameters);
// this prints {facetFilters: [], optionalFilters: [], numericFilters: [], tagFilters: []}

Running this as as a command line app at the moment. Am I not using setFacetFilter correctly?

Unacknowledged Pull Requests / Lack of Maintenance

I just noticed that after I created PR #67 one week ago, you went ahead and committed 9e60161 without any notice. There has not been a single comment on any of the related PRs or issues this addresses.

Instead, you simply took the code from the PRs with minor adjustments and committed them yourself. This is IMO not an acceptable practice for an open source repo and I wish we could (together) improve maintenance on this repo!
This is probably not really legal either considering copyright.

Allow support for custom Http client

Is your feature request related to a problem? Please describe.
We use a custom http client in our project for things like performance metrics and analysis and would like to be able to use it with our Algolia query too.

Describe the solution you'd like
right now you use the standard http.post method from the http package, that method is actually a shortcut for a call to Client().post from the same package. The same is true for the others method of the package.
Adding an optional parameter for a custom Client to method like getObjects and replacing call to http.post by a call to this custom client.post when the custom client is available would likely solve this problem.

Describe alternatives you've considered
We tried to use our current performance monitoring by encapsulating our call to this library in it but we haven't managed yet to have functional traces on Firebase Performance for example, that's why we decided to ask for this feature.
It also had the issue of partial code duplication between our custom Http Client and this encapsulation.

Algolia search in flutter, index issue.

I am trying to provide search in flutter app using algolia. But i have different results coming from it.
I search with one keyword in website and in app. In both i get different results. In app using algolia, i have found that 5 results from the top of the list are not getting displayed in my flutter app.
Amy suggestions you have on how to achieve this?
I have added hits per page and page for pagination.
If i remove them, then i get the proper results, but i need to add pagination in my app also.

Algolia and Firebase Incompatibility

I am trying to use algolia dart package to my angular dart application and I have encountering compatibility issues with firebase ^5.0.2 because it uses/depends on http ^0.11.3 and algolia depends on http ^0.12.0.

Can algolia be forced or modified to also use http ^0.11.3 to http ^0.12.0.

Search on two parameters

how to search/match on two search parameters . Searching the review index to match on ProductID and then searchtext on comments

_algoliaApp.instance
.index("review")
.search(widget.productID)
.search(widget.searchText)

CERTIFICATE_VERIFY_FAILED: application verification failure on iOS simulator

Dart version: [eg: 2.12.0]
Flutter version: [eg: 2.0.0 (stable)]

Describe the bug
Starting with v1, I get the error in the title when using an iOS simulator. Physical iOS devices work fine.

To Reproduce
Steps to reproduce the behavior:

  1. Attempt to use .query in a flutter app running on an iOS simulator

Expected behavior
I expect there to be no error and my .query call to return results

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Device: [e.g. iPhone 12 Pro Max]
  • OS: [e.g. iOS14.3]

Dependency on old version of http

I'm getting stuck at the null-safety migration because I have other packages that depend on http ^0.13.0, but algolia depends on http ^0.12.0.
Could you please upgrade the version for the http package dependency?

deleteObject() fails with: "Path not supported by Algolia REST API."

object([String? path]) accepts a parameter path which I thought was unusual as I hadn't heard that term, then when I use it and then use deleteObject() I get the mentioned error.

await algolia
   .index('foobar')
   .object(objectId)
   .deleteObject();

fails with:

{message: Path not supported by Algolia REST API. Please have a look at http://www.algolia.com/doc/rest_api for the list of valid commands, status: 404}

Aloglia docs for deleteObject:
https://www.algolia.com/doc/rest-api/search/#delete-object

setInsidePolygon method does not support polygons, but triangles only

Dart version: 2.7
Flutter version: >=2.6.0 <3.0.0

Implementation of the setInsidePolygon method does not support polygons, but triangles only:

AlgoliaQuery setInsidePolygon(List value) {
assert(value != null && value.isNotEmpty, 'value can not be empty');
assert(!_parameters.containsKey('insidePolygon'));
List<List> list = value
.map((v) => [v.p1Lat, v.p1Lng, v.p2Lat, v.p2Lng, v.p3Lat, v.p3Lng])
.toList();
return _copyWithParameters(<String, dynamic>{'insidePolygon': list});
}

According to algolia api documentation, any even number of coordinates should work:
"To specify multiple polygons, pass an list of lists of floats (each inner array must contain an even number of values, with a minimum of 6)". [https://www.algolia.com/doc/api-reference/api-parameters/insidePolygon/]

Probably, the BoundingPolygonBox class should contain a List of numbers, not just six parametres: num p1Lat; num p1Lng; num p2Lat; num p2Lng; num p3Lat; num p3Lng;

setFacetFilter() not returning filtered items

For some reason the following code only works when the isEnabled:true and isDeleted:false facet filters are not set. When I add them in, I get nothing returned.

String filter = 'categoryId:1';
query = query.setFacetFilter(filter);
query = query.setFacetFilter('isEnabled:true');
query = query.setFacetFilter('isDeleted:false');
query = query.setAroundLatLng('${userLocation.latitude}, ${userLocation.longitude}');
query = query.setAroundRadius(distance > 0 ? distance : 'all');

I should receive all of the items that have isDeleted set as false and isEnabled set as true. My flutter doctor is below.

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-CA)
• Flutter version 1.12.13+hotfix.5 at /Users/zee/flutter
• Framework revision 27321ebbad (3 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/zee/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.7.1

[✓] Connected device (1 available)
• Pixel 3 XL • 8BNY11DRQ • android-arm64 • Android 10 (API 29)

• No issues found!

Bug in AlgoliaQuery setAroundRadius(dynamic value)

Dart version: 2.1.2
Flutter version: 0.1.4+3

Describe the bug
It is impossible to add setAroundRadius parameter, because of negation (value is int || (value is String && value == 'all'))

Expected behavior

Change code in query.dart (remove negation) from:

AlgoliaQuery setAroundRadius(dynamic value) {
    assert(value != null);
    assert(!_parameters.containsKey('aroundRadius'));
    assert(!(value is int || (value is String && value == 'all')),
        'value must be a `int` or `"all"`');
    return _copyWithParameters(<String, dynamic>{'aroundRadius': value});
  }

to:

AlgoliaQuery setAroundRadius(dynamic value) {
    assert(value != null);
    assert(!_parameters.containsKey('aroundRadius'));
    assert((value is int || (value is String && value == 'all')),
        'value must be a `int` or `"all"`');
    return _copyWithParameters(<String, dynamic>{'aroundRadius': value});
  }

Runtime exception when using setHitsPerPage in multi query

Dart version: 2.7.0
Flutter version: v1.12.13+hotfix.6

Describe the bug
The following code raises a runtime exception:

    final queries = App.algolia.multipleQueries;
    queries.addQuery(App.algolia.index('my_index').setHitsPerPage(1));
    queries.getObjects();

It looks like the URI constructor when building the request payload needs the values of the query parameters to be String|Iterable<String> : https://api.dartlang.org/stable/2.7.0/dart-core/Uri/Uri.html
The value of parameter hitsPerPage is an int, so the constructor fails.

Error in AlgoliaQuerySnapshot

Flutter 2.2.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f4abaa0735 (2 weeks ago) • 2021-07-01 12:46:11 -0700
Engine • revision 241c87ad80
Tools • Dart 2.13.4
algolia: ^1.0.1

Describe the bug
AlgoliaQuerySnapshot throw exception "I/flutter (13087): type 'Null' is not a subtype of type 'int'"

To Reproduce
Steps to reproduce the behavior:
Make a query and call getObejects() method these are my parameters used:

image

The problem is when used:

AlgoliaQuery query =
        algolia.instance.index(index!).setOffset(from).setLength(size);

If you use setPage() work ok.

Expected behavior
Return the Algolia result

Screenshots
image

image

The map object don't have all key values

Additional context
After update to null safety the exception thrown.

Failed host lookup: 'wzgqmequtp-dsn.algolia.net' (OS Error: nodename nor servname provided, or not known, errno = 8)

Dart version: 2.9.0
Flutter version: 1.19.0-4.1.pre

Describe the bug
This is caught during setSettings method and persists on iOS with active internet connect.

To Reproduce
Steps to reproduce the behavior:
try{ AlgoliaSettings settings = await algolia.index('Indice').settings; }catch(e){ //SocketException: Failed host lookup: 'wzgqmequtp-dsn.algolia.net' (OS Error: nodename nor servname provided, or not known, errno = 8) }

Desktop (please complete the following information):

  • OS: Mac

Smartphone (please complete the following information):

  • Device: iOS Simulator, iOS Device
  • OS: 13.5.1

Algolia setFacetFilter array

I noticed with this package that when setting a facet filter you can pass in strings which when it posts to Algolia it makes it an AND call on the index.

If you want to query OR the format is this:

"facetFilters": [
[
"location:Cape Town",
"location:Durban"
]
]

but if you pass the array as a string it doesn't format correctly and it retrieves 0 hits:

"facetFilters": [
"[location: Bloemfontein, location: Cape Town]"
],

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.