#community-help

Facetting Field Inside Object Array in GH Issue

TLDR Michael enquires about faceting fields inside an object array and GH issue. After clarifying facets' syntax and usage, Kishore Nallan explained how to handle the situation, which resolved Michael's issue.

Powered by Struct AI
Aug 04, 2023 (4 months ago)
Michael
Photo of md5-ab9a5d60cb7ebd0211d1a368b45a0473
Michael
01:07 PM
Ah found it in a GH issue:

When you search on an object field name, all sub-fields will be automatically searched. Use a dot notation to refer to sub-fields, e.g. person.last_name or person.school.name.

Kishore Nallan Jason ^ maybe add that to the query_by docs ^^
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:07 PM
Will do!
Michael
Photo of md5-ab9a5d60cb7ebd0211d1a368b45a0473
Michael
01:09 PM
On that note, can a field inside of an object array be used for facetting?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:10 PM
Yes that should be possible. Let me know if it does not work.
Michael
Photo of md5-ab9a5d60cb7ebd0211d1a368b45a0473
Michael
01:11 PM
I don't really find documentation on how to configure that either.

you have the facet => true thing on a field, but how to tell the facet, that it should only facet e.g. the category title in an objectarray of categories, and not the category description?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:12 PM
facet_by=category.title
01:13
Kishore Nallan
01:13 PM
Instead of defining facet => true on the parent object/object array, define a field specifically with dots in the name e.g. foo.bar.baz and set that to facet => true
Michael
Photo of md5-ab9a5d60cb7ebd0211d1a368b45a0473
Michael
01:14 PM
so you'd create simply e.g.:

address = object

and then

address.county.title = string

In the TS structure if I get this correctly?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:32 PM
Correct
Michael
Photo of md5-ab9a5d60cb7ebd0211d1a368b45a0473
Michael
05:42 PM
Thank you very much!