I have a search form which provides searching properties for holiday in a specific country based on it's availability specific date. Search section has 2 sections "basic search" & "advance search".
Basic search contains country dropdown and date field. In advance search we have multiple filters for hotels like "Bedrooms" (1 bedroom, 2 bedroom etc) and then property type (apartment, villa, etc)
I want to show the search filter options with a count such as "1 bedroom (23 properties)" and same for other search filter options.
I am using php/mysql to create this application, so what comes first in my mind is to run multiple queries for all search filters and get the COUNT result from mysql and show it. I have about 10-12 different filters on my page. Also I have to show count records dynamically based on all search options (basic and advanced) selected.
Running multiple queries on the page will make it load forever and it will not show content due to multiple query load. Is there any better & faster way to do this?
Please help, thanks!
解决方案
What you're trying to achieve is called faceted search.
This isn't a problem suited to a relational database like MySQL.
Just remember that these are search servers and don't replace your main database. They only perform search operations that return the IDs that correspond to the actual records stored in your database. You still need MySQL (or MongoDB etc).