The current API filters are quite handy, but lack the ability to support powerful searching of large texts. I’d like to see the ability to define custom search endpoints/fields that provide scored, elastic-like search results. The ultimate goal is to to give customers the ability to build Google-like SERPs on top on their GraphCMS models.
I’d imagine a new type, called Index
, where I can:
This has come up in conversation on Slack, which yielded a few options for how to go about building it:
SearchResult
type).Option 1 seems doable, but so limited as to be pointess (I’d just stand up my own search service and syndicate GraphCMS data to it). Same for Option 2.
Option 3 is the pie-in-the-sky option, but requires Prisma to support union types, which they’ve been pretty quiet about recently.
Option 4 might be the best hybrid approach. Essentially, when you define an index, you’re also defining a new model to represent the results. When you add a new type to the index, you choose which fields from that model map to the fields in your index (e.g., title, description, date, preview image, etc.). That way you have a consistent interface that doesn’t require a union type. They could also provide their original type, if you wanted to fetch more fields in subsequent calls.
Having thought about it some more, I think some flavor of option 4 would be both the best and easiest approach. Defining a CMS type for each index is like a type in elastic, and mapping fields of a GraphCMS type when you add it to a search index would provide all you need to map fields in the underlying elastic indexes, if you were to build it on elastic. The UX for that wouldn’t be bad at all, and could remain quite consistent with the existing GraphCMS flows.
I know some of the implementation specifics have changed in recent versions of elastic, but the principles are the same.
any updates on this ?