I want to write a more complex autocomplete search for a craft site. I know there are already some posts here that go in that direction. As they also tried, I approach this problem first by using the Element API. However, it does not work nicely with multiple queries.
That's my situation: I have a database with items that have also a category assigned to them and sometimes are linked to a second section.
I would now like the autocomplete to show 3 types of results:
- Entries where the title matches the search term (this can be easily done with Element API)
- The categories that match the search term, labelled with "Jump to Category: Title"
- The entries of the linked section that match the search term, also labelled accordingly.
So the autocomplete suggestions at the end would list all three types of entries, labelled accordingly.
I can obviously run three different calls to element API but that seems rather inconvenient and ineffective.
Is there any better way to do this?