Quick question, not sure if I missed it: is there ...
# community-help
b
Quick question, not sure if I missed it: is there a way to retrieve multiple documents by ID in one request? Use case is that we run a ~90k document lunr index in the user's browser, so that search feels instant even when connection is crap, but that only holds title and ID for obvious resource contraint reasons, and we'd love to in a second step then augment those results by fetching the remaining data out of Typesense.
j
Yup, you can do
filter_by: id:=[1,2,3]
b
Perfect!
It's a special extra layer for one of 4 indices, the other ones already work like a charm directly out of Typesense, where federated hums with lots of data and vector searches are doing exactly what they should, really solid job!
j
That’s great to hear! 🙏
b
Uhm, stupid question @Jason Bosco re fetching a set of docs as per above: is there a way to POST a simple search (JSON \`q:'*', filter...`) in a collection or do I always need to build a GET request string?
Tried posting to
<http://localhost:8108/collections/foo/documents/search>
Which 404s
j
You can send a POST with a JSON structure to the multi_search endpoint even it’s just a single search
b
Got it, thats the one we're using so far - performance should be the same?
j
Yup
b
Thanks a lot as always!
👍 1
Quick follow up: works, but the results have a different order than the array of IDs we filtered by - is there a way to preserve it?
j
Filtering is not order-preserving… You would have to use the sort_by parameter to preserve order, or alternatively use the pinned_hits search parameter
b
Got it, its a short list with no predictable order we can pass to typesense sort_by so think sorting it in the client makes most sense.
👍 1
Darn, its such a pleasure working with Typesense, it's when youre not sure and the give it a shot anyway and it just works flawlessly...
😄 1
DId
this.current.results.plants.items.map(function(el,i){order += el.id + ':' + (i+1) + ',';buffer.push(parseInt(el.id))})
and used pinned and works like a charm, thank you!
🙌 1
👍 1