algolia / algoliasearch-client-dart

⚡️ A fully-featured and blazing-fast Dart/Flutter API client to interact with Algolia
MIT License
12 stars 7 forks source link

searchSingleIndex doesn't support offset,length pagination query #4

Open LaysDragon opened 10 months ago

LaysDragon commented 10 months ago

When passing offset,length parameter into searchSingleIndex ,the response have different data then what decoder expect causing error.

I/flutter (11302): CheckedFromJsonException
I/flutter (11302): Could not create `SearchResponse`.
I/flutter (11302): There is a problem with "hitsPerPage".
I/flutter (11302): type 'Null' is not a subtype of type 'int' in type cast
I/flutter (11302): #0      $checkedConvert (package:json_annotation/src/checked_helpers.dart:91:5)
I/flutter (11302): #1      $checkedCreate.checkedConvert (package:json_annotation/src/checked_helpers.dart:28:7)
I/flutter (11302): #2      _$SearchResponseFromJson.<anonymous closure> (package:algolia_client_search/src/model/search_response.g.dart:41:39)
I/flutter (11302): #3      $checkedCreate.<anonymous closure> (package:json_annotation/src/checked_helpers.dart:33:22)
I/flutter (11302): #4      $checkedNew (package:json_annotation/src/checked_helpers.dart:51:23)
I/flutter (11302): #5      $checkedCreate (package:json_annotation/src/checked_helpers.dart:30:10)
I/flutter (11302): #6      _$SearchResponseFromJson (package:algolia_client_search/src/model/search_response.g.dart:10:5)
I/flutter (11302): #7      new SearchResponse.fromJson (package:algolia_client_search/src/model/search_response.dart:234:7)
I/flutter (11302): #8      deserialize (package:algolia_client_search/src/deserialize.dart:454:29)
I/flutter (11302): #9      SearchClient.searchSingleIndex (package:algolia_client_search/src/api/search_client.dart:1987:12)
I/flutter (11302): <asynchronous suspension>
andrasfecz commented 2 months ago

Using the same thing searchSingleIndex, passing offset & length but getting a different error about 'page' missing. Page should not be required if using offset & length

com.algolia.client.exception.AlgoliaClientException: Illegal input: Key page is missing in the map.
    at com.algolia.client.exception.internal.ThrowableKt.asClientException(Throwable.kt:10)
    at com.algolia.client.transport.internal.KtorRequester.onError(KtorRequester.kt:109)
    at com.algolia.client.transport.internal.KtorRequester.execute(KtorRequester.kt:74)
    at com.algolia.client.transport.internal.KtorRequester$execute$1.invokeSuspend(Unknown Source:14)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:102)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
Caused by: io.ktor.serialization.JsonConvertException: Illegal input: Key page is missing in the map.