Is there an easy way to get range of values from a...
# community-help
p
Is there an easy way to get range of values from a particular field after a search query? For e.g. lets say I have a collection with 100k documents with two fields : "name" (string) and "price"(float). I perform a search that returns 10k documents, which can be displayed at max 250 documents / page - so 40 pages. I want to figure out the min, median, and max price values across the 10k returned documents. The only way I can think of is to retrieve values from page #1 (min price), page#21 (median price), and page#40(max price) if my results are sorted on price:asc. Is there a simpler way to retrieve a list of all price values from the 10k documents, so I can get the min,max,median more easily?
Btw I have also tried to facet on the "price" field, but that takes an inordinate amount of time, so I assumed that is probably not the most efficient way to go, esp as my collection size increases
j
Hi @Prajjval Dixit, faceting on price would be the way to get min max avg. I’m surprised to hear that it takes a long time. The songs demo for example has 32M records and for every search we facet on artist, genre, release date, etc and it still returns in less than a second. Could you share the exact query you’re using?
Hmm, did you send a message @Prajjval Dixit? I got a new message notification with your name, but I don’t see new messages above after my last question...
p
Hi @Jason Bosco - I misspoke earlier. What I meant was uploading documents to the collection while faceting was taking a lot of time. I did realize that I was defining my datatype incorrectly. The issue is solved now, thanks!
j
Ah ok. Typesense should show you a validation error if it receives the wrong data type. Did it just hang?