typesense / typesense-dart

Dart client for Typesense
https://typesense.org/docs
Apache License 2.0
73 stars 16 forks source link

preset appears to be ignored in request from Dart #136

Closed jordan112 closed 9 months ago

jordan112 commented 9 months ago

The presets passed in don't seem to work. I get an error stating i need to add query parameters, when i thought that the preset would be the only thing I need.

Steps to reproduce the behavior:

  1. Generate a search query
  2. don't add query params only use reset
  3. get error stating no query params were declared

Expected behavior

It should be able to only use the preset without specifying query or sort parameters, so preset can be managed from Typesense cloud and not update client

Screenshots

None

Additional context

 final searchParameters = {
      'q': searchKey, // Access searchKey property using the null-aware operator
      'per_page': pageSize.toString(),
      'page': (pageKey + 1).toString(),
      'preset': 'inventory_search',
      'query_by':
          'category,notes,origin,status,title,listingPlatforms,soldPlatform',
      'filter_by': filterBy,
      "sort_by": sortString,
      "facet_by": "category,status",
    };
happy-san commented 9 months ago

Hello @jordan112 Could you also share the preset definition?

happy-san commented 9 months ago

I tried to create to create the following preset and it worked fine for me.

  await client.presets.upsert('query_field_preset', {
    'value': {
      'query_by': 'company_name',
    }
  });

  await client.collection('companies').documents.search(
    {
      'q': 'Corp',
      'preset': 'country_filter_preset',
      'filter_by': 'country:=USA',
    },
  );
jordan112 commented 9 months ago

This appears to be working now. At one point while implementing, i got errors stating query parameters were required even though i had a preset. closing this issue.

Here is my preset for reference

image