Skip to content

Unable to make search query with group by, with the error: json: cannot unmarshal number into Go struct field SearchGroupedHit.grouped_hits.group_key of type map[string]interface {} #141

@vamshiaruru32

Description

@vamshiaruru32

Description

When I make a search query with group by, I get the error

json: cannot unmarshal number into Go struct field SearchGroupedHit.grouped_hits.group_key of type map[string]interface {}

Steps to reproduce

	filterString := fmt.Sprintf("productSlug:=%s", productSlug)
	searchParams := &api.SearchCollectionParams{
		Q:          "*",
		QueryBy:    "searchText0,searchText1,searchText2",
		FilterBy:   &filterString,
		GroupBy:    utils.Ref("productID"), // utils.Ref just gets a pointer
		GroupLimit: utils.Ref(1),
	}
	resp, err := tsClient.Collection(collection).Documents().Search(searchParams)

And here's the schema

{
  "name": "product_variants_all",
  "fields": [    
    {
      "name": "searchText0",
      "type": "string",
      "facet": false,
      "optional": false,
      "index": true,
      "sort": false,
      "infix": false,
      "locale": ""
    },
    {
      "name": "productSlug",
      "type": "string",
      "facet": false,
      "optional": false,
      "index": true,
      "sort": false,
      "infix": false,
      "locale": ""
    },
    {
      "name": "searchText1",
      "type": "string",
      "facet": false,
      "optional": false,
      "index": true,
      "sort": false,
      "infix": false,
      "locale": ""
    },
    {
      "name": "searchText2",
      "type": "string",
      "facet": false,
      "optional": false,
      "index": true,
      "sort": false,
      "infix": false,
      "locale": ""
    },
    {
      "name": "rankingScore",
      "type": "float",
      "facet": false,
      "optional": false,
      "index": true,
      "sort": true,
      "infix": false,
      "locale": ""
    },
    {
      "name": "productID",
      "type": "int32",
      "facet": true,
      "optional": false,
      "index": true,
      "sort": true,
      "infix": false,
      "locale": ""
    }
  ],
  "default_sorting_field": "rankingScore",
  "enable_nested_fields": true,
  "symbols_to_index": [],
  "token_separators": []
}

Expected Behavior

No error

Actual Behavior

Unmarshal error

Metadata

Typesense Version: 0.24.1

OS: Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions