typesense / typesense-swift

Swift Client for Typesense ⚡️🔎
https://typesense.org/docs/
Apache License 2.0
39 stars 16 forks source link

group_limit and page search parameters not give output #41

Closed NikunjChaudhari closed 1 week ago

NikunjChaudhari commented 1 week ago

Description

Unable to use page , groupLimit etc as they asked int type in searchparameter but in response getting errors like "Parameter `group_limit' must be an unsigned integer."

Steps to reproduce

add searchParameters with page: 1 and grouplimit: 1

Screenshot 2024-11-05 at 10 19 37 AM

Expected Behavior

it should give response based on page and group_limit screenshot added below

Screenshot 2024-11-05 at 10 36 21 AM

Actual Behavior

Screenshot 2024-11-05 at 10 26 48 AM

here in SearchParameters i added page: 1, groupLimit: 1 while generate search parameter like this

let searchParameters = SearchParameters(q: parameters.q, queryBy: "productName,brandTitle,categoryList.categoryName,colourName", sortBy: "availableQuantity:desc,_text_match:desc,popularScore:desc", page: 1, perPage: 10, groupBy: "parentProductId", groupLimit: 1, excludeFields: "embedding,product_name_vector,detailDescription_vector,searchAbleAttributes,detailDescription,images.extraLarge,images.large,images.small")

but while api call curl generate and it become true value for page and group_limit and give error like { "message": "Parameter group_limit must be an unsigned integer." }

and

{ "message": "Parameter page must be an unsigned integer." }

Metadata

Typesense Version: 1.0.0

OS: iOS Version 18.0.1

phiHero commented 1 week ago

Hi @NikunjChaudhari

I could not reproduce the issue. Could you enable debug mode and provide me the logs?

let myConfig = Configuration(nodes: [node], apiKey: AppChangab1es.typeSenseSearchAPIKey,
connectionTimeoutSeconds: 10, logger: Logger(debugMode: true))

In my case both the page and group_limit parameters are correct.

Request #1730811408287: Attempting GET request: Try 1 to Node: http://localhost:8108/collections/companies/documents/search
Request 1730811408287: Request to http://localhost:8108/collections/companies/documents/search?q=*&query_by=company_name&sort_by=_text_match:desc&page=1&per_page=10&group_by=country&group_limit=1&exclude_fields=num_employees was made. Response Code was 200
NikunjChaudhari commented 1 week ago

@phiHero getting this error from logger

Request 1730816050699: Request to https://xrvu2bd0fjqz3y8ep-1.a1.typesense.net:443/collections/staging_sold_products/documents/search?sort_by=availableQuantity:desc,_text_match:desc,popularScore:desc&group_limit=true&q=Men&per_page=30&group_by=parentProductId&query_by=productName,brandTitle,categoryList.categoryName,colourName&page=true&exclude_fields=embedding,product_name_vector,detailDescription_vector,searchAbleAttributes,detailDescription,images.extraLarge,images.large,images.small was made. Response Code was 400 Error searching products: clientError(code: 400, desc: "Request failed with HTTP code 400 | Server said: Parameter group_limit must be an unsigned integer.")

for request i am passing page:1 and groupLimit:1 which you can refer from below attachment

Screenshot 2024-11-05 at 7 41 00 PM
phiHero commented 1 week ago

@NikunjChaudhari Does this also happen when you set the value to an integer other than 1? I'm thinking if the number 1 is being converted to true and 0 converted to false.

NikunjChaudhari commented 1 week ago

@phiHero yes have issue with value 1 only for page 2 and groupLimit 2 its working fine

Request 1730816934165: Request to https://xrvu2bd0fjqz3y8ep-1.a1.typesense.net:443/collections/staging_sold_products/documents/search?exclude_fields=embedding,product_name_vector,detailDescription_vector,searchAbleAttributes,detailDescription,images.extraLarge,images.large,images.small&page=2&group_limit=2&query_by=productName,brandTitle,categoryList.categoryName,colourName&sort_by=availableQuantity:desc,_text_match:desc,popularScore:desc&q=Men&per_page=2&group_by=parentProductId was made. Response Code was 200

phiHero commented 1 week ago

OK found the bug! Fix should be right away

phiHero commented 1 week ago

Thanks for pointing that out @NikunjChaudhari. The fix is included in https://github.com/typesense/typesense-swift/pull/39

phiHero commented 1 week ago

@NikunjChaudhari could verify with v1.0.0-rc.1?

NikunjChaudhari commented 1 week ago

@phiHero yes i verified its working fine here are success logs

Request 1730867388631: Request to https://xrvu2bd0fjqz3y8ep-1.a1.typesense.net:443/collections/staging_sold_products/documents/search?exclude_fields=embedding,product_name_vector,detailDescription_vector,searchAbleAttributes,detailDescription,images.extraLarge,images.large,images.small&sort_by=availableQuantity:desc,_text_match:desc,popularScore:desc&group_limit=1&page=1&query_by=productName,brandTitle,categoryList.categoryName,colourName&group_by=parentProductId&q=Men&per_page=30 was made. Response Code was 200

@phiHero thank you for quick response and resolved it