search menu with result count per option
Asked Answered
P

2

8

On various websites there is a search bar that already depicts the amount of results you will get per option you can select.

In some cases there is a tenfold of options you can choose from and for each option you already see if you select this option you will get 102 results, 88 results, etc. This is all provided within a fraction of a second.

Does anybody know how this is done? In case you use a relational database you will have to run thousands of queries to calculate the result for each option, per user checking the website. This will take too much time. Also caching every possible option is almost impossible, since it will generate millions of possibilities and whenever something changes you can start caching again.

Is there some other kind of decision-tree database that already provides the amount of results per option?

See for example this house-search website where you can select tens of options for the house you are looking for (menu at the left hand side).

https://www.funda.nl/koop/amsterdam/

Paravane answered 20/7, 2018 at 11:31 Comment(0)
G
2

counting each result is what requires computing power, however this website seems to run functions this way

1: get lOCATION(input)  

2: SELECT COUNT(*)
  FROM LOCATION.COLUMNS
 WHERE room_catalog = 'database_name' 
   AND table_name = 'table_name

SQL for instance is quick at iterating through databases but returning all the possibilities and then selecting which ones have 1 room and which ones have 2 rooms would take a lot of computing power and time.

this is why structure is important and also using the correct programming language for quick backend processing. if i'm not mistaken there is a high chance this website is using Python for their backend handling just like google.

Griffie answered 24/8, 2018 at 10:16 Comment(0)
R
0

If you can populate a table with all the values that can show up in your suggestion, you can add another column to map the availability, cost etc against each suggestion. You could write code to calculate that particular value when adding new suggestions to the table and also when the value in question changes. Then you could fetch both suggestions and the required value at the same time and display it to the user.

This approach will require the following

1)Know all the values that can be suggested, like places or products

2)Trigger events when new values for suggestions come, like adding a new product/place

3)Trigger events when the value in question, like price or availability, changes

Remington answered 23/8, 2018 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.