根据用户完成的搜索对搜索条件记录进行计数(MYSQL PHP) [英] Count search criteria record based on search done by user (MYSQL PHP)

查看:204
本文介绍了根据用户完成的搜索对搜索条件记录进行计数(MYSQL PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索表单,该表单根据可用性的特定日期为特定国家/地区的假期提供搜索属性.搜索部分有2个部分基本搜索"和"高级搜索".

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".

基本搜索包含国家/地区下拉列表和日期字段.提前搜索,我们为酒店提供了多个过滤器,例如卧室"(1间卧室,2间卧室等),然后是物业类型(公寓,别墅等)

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)

我想显示带有"1卧室(23个属性)"之类的计数的搜索过滤器选项,其他搜索过滤器选项也是如此.

I want to show the search filter options with a count such as "1 bedroom (23 properties)" and same for other search filter options.

我正在使用php/mysql创建此应用程序,因此我首先想到的是对所有搜索过滤器运行多个查询,并从mysql获取COUNT结果并将其显示.我的页面上大约有10-12个不同的过滤器.另外,我还必须根据所选的所有搜索选项(基本和高级)动态显示计数记录.

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?

请帮助,谢谢!

推荐答案

您要实现的目标称为分面搜索.

这不是适合像MySQL这样的关系数据库的问题.

This isn't a problem suited to a relational database like MySQL.

您可以使用 ElasticSearch 请记住,这些是搜索服务器,不会替换您的主数据库.它们仅执行返回与存储在数据库中的实际记录对应的ID的搜索操作.您仍然需要MySQL(或MongoDB等).

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).

这篇关于根据用户完成的搜索对搜索条件记录进行计数(MYSQL PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆