#community-help

Overcoming Query String Error with Multi-Search in Flutter

TLDR Andrew was getting a query string error and tried to switch to multi-search. Jason helped them implement it correctly, clarifying the differences between single and multi-search, and confirmed that the multi-search is unbounded.

Powered by Struct AI

1

Nov 02, 2022 (14 months ago)
Andrew
Photo of md5-7766f890de99fa72a6d81315691a6758
Andrew
09:48 PM
hey guys, im getting this error:

"Query string exceeds max allowed length of 4000. Use the /multi_search end-point for larger payloads."

How would i get around this? Im using flutter so i dont know if i need to change the search function. For reference, that function looks like:

  Future<Map<String, dynamic>> search(
      Map<String, dynamic> searchParameters) async {
    return await _apicall.get(
      '$_endPoint/search',
      queryParams: searchParameters,
      shouldCacheResult: true,
    );
  }

Will changing /search to /multiSearch work?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:52 PM
Correct, you would have to switch to using multi search
Andrew
Photo of md5-7766f890de99fa72a6d81315691a6758
Andrew
09:57 PM
Im having a bit of trouble editing the package's file. I created
Future<Map<String, dynamic>> multiSearch(
      Map<String, dynamic> searchParameters) async {
    return await _apicall.get(
      '$_endPoint/multi_search',
      queryParams: searchParameters,
      shouldCacheResult: true,
    );
  }

Inside of documents.dart, but when i try to call the method, i get
Error: The method 'multiSearch' isn't defined for the class 'Documents'.
lib/…
- 'Documents' is from 'package:typesense/src...').
package:typesense/src/documents.dart:1
Try correcting the name to the name of an existing method, or defining a method named 'multiSearch'.
        await _typesenseClient.collection('users').documents.multiSearch({
                                                             ^^^^^^^^^^^

Any idea why this doesnt work?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:09 PM
Multi search is already implemented in the dart library, so you can use it directly like in the code sample here: https://typesense.org/docs/0.23.1/api/federated-multi-search.html
Andrew
Photo of md5-7766f890de99fa72a6d81315691a6758
Andrew
10:45 PM
I think i got it working, is there a drawback to using multisearch instead of normal search? Ie why not use it by default?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:00 PM
We had single collection search first and we added multi search in a later version to search across collections efficiently. But you can still use multi search to search just one collection. There are no differences except that multi search uses post and single collection search uses GET
Andrew
Photo of md5-7766f890de99fa72a6d81315691a6758
Andrew
11:55 PM
Awesome, thanks!
11:55
Andrew
11:55 PM
And slightly related, but i had to switch because i hit the string length limit for a query on single search. Is multi search unbounded?
Nov 03, 2022 (14 months ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:24 AM
Correct

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Handling Search Limitations and Results Parsing in Typesense

Loic faced difficulties with Typesense search result limits and parsing results in Dart. Jason advised using the export endpoint to avoid limits and splitting the JSONL formatted result string by newline for parsing.

11
20mo

Understanding and Implementing Typesense Dart Library with Flutter

Alexandro sought help with the Typesense Dart library. Jason explained that the library is in progress, discussed utilizing other HTTP libraries, and provided detailed instructions on utilizing Typesense with Flutter. Alexandro provided feedback on the Typesense UI and expressed interest in creating a tutorial video.

10

82
32mo

Discussion on the Use of `TypesenseInstantSearchAdapter`

DavidLo sought advice to retrieve search results using `TypesenseInstantSearchAdapter`. Carl and Jason advised using `typesense-js` and features like `documents/export`, `documents/search`, `multisearch`, and pagination. The potential server-side solution and bundle size issues concerning the exposure of the search client were also discussed.

2

17
26mo

Multiple Filters and JSON Requests in Typesense

Manish asked about multiple filter_by arguments, JSON input, and using multisearch. Jason offered typesense documentation links, examples, and how to use JSON formatted requests with multisearch. Ed shared a similar use case.

6

44
5mo

Trouble Spotting API Error in Dart vs Shell Operations

Erick is having issues with the typesense API, receiving errors in Dart that are not present in shell operations. Despite Kishore Nallan trying to help, no solution has been found, leading Erick to post the issue on the dart client repository.

30
23mo