在客户端使用PHP或JavaScript从大量数据中通过大量关键字一一搜索
表 1 - 包含以十万为单位的数据(列:id、title、description)
表 2 - 包含 25k 个关键字。(列:id,关键字)
现在我想在 Table1 中逐个关键字搜索数据,但我只想从 Table1 中的 2-3k 数据中搜索(仅在标题、描述列中)。
所以我计划,首先在一些对象(如数据表、数组等)中获取那些 2-3k 数据,然后在对象中逐个搜索关键字,并且当任何关键字在 Table1 中匹配时(仅在标题、描述列中)。MATCH[] 数组中这些数据的对象存储 ID 与 NOTMATCH[] 数组中存储的数据 ID 不匹配。
示例:Table1(100 000 行)
id title description
1 dell laptop laptop i3 5000 xyz
2 hp machine hp xyz abc utr
3 supply motor 1500 Decorative Watches
4 Deep Groove Drill Ball Bearing Deep Hole Drill
示例:Table2(26 000 行)
id keyword
1 dell
2 Drill
这是我的代码。我希望对其进行一些改进以实现快速..或其他逻辑。当任何关键字输入搜索输入并显示结果时,就像引导数据表客户端搜索过程一样工作。
<html>
<body>
<?php
//this data from table1
$data = array(
"0"=>array(
"ID" => "1234",
"title" => "dell laptop",
"description" => "dell laptop i3 5000 xyz",
),
"1"=>array(
"ID" => "1238",
"title" => "hp machine",
"description" => "hp xyz abc utr",
),
"2"=>array(
"ID" => "1240",
"title" => "supply motor 1500",
"description" => "Decorative Watches",
),
"3"=>array(
"ID" => "1245",
"title" => "Deep Groove Drill Ball Bearing",
"description" => "Deep Hole Drill",
),
);
$MATCH =array();
$NOTMATCH =array();
$keywords =array('dell','watches'); //this data from table2
echo "<pre>";
</body>
</html>
那么我怎样才能按照我的计划编写代码。
慕斯王
桃花长相依
相关分类