久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

PHP/MySQL 小規(guī)模模糊搜索

PHP/MySQL small-scale fuzzy search(PHP/MySQL 小規(guī)模模糊搜索)
本文介紹了PHP/MySQL 小規(guī)模模糊搜索的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我希望為一個(gè)小型 PHP/MySQL 應(yīng)用程序?qū)崿F(xiàn)模糊搜索.具體來說,我有一個(gè)包含大約 2400 條記錄的數(shù)據(jù)庫(kù)(記錄以每年大約 600 條的速度添加,因此它是一個(gè)小型數(shù)據(jù)庫(kù)).三個(gè)感興趣的字段是街道地址、姓氏和日期.我希望能夠通過這些字段之一進(jìn)行搜索,并且基本上可以容忍拼寫/字符錯(cuò)誤.即,123 Main Street"的地址還應(yīng)與123 Main St"、123 Main St."、123 Mian St"、123 Man St"、132 Main St"等匹配,名稱也是如此和日期.

I'm looking to implement fuzzy search for a small PHP/MySQL application. Specifically, I have a database with about 2400 records (records added at a rate of about 600 per year, so it's a small database). The three fields of interest are street address, last name and date. I want to be able to search by one of those fields, and essentially have tolerance for spelling/character errors. i.e., an address of "123 Main Street" should also match "123 Main St", "123 Main St.", "123 Mian St", "123 Man St", "132 Main St", etc. and likewise for name and date.

我在回答其他類似問題時(shí)遇到的主要問題:

The main issues I have with answers to other similar questions:

  • 不可能為每個(gè)可能的錯(cuò)誤拼寫定義同義詞,忘記為日期和名稱定義同義詞.
  • Lucene 等對(duì)于如此有限的搜索數(shù)據(jù)集來說似乎非常重要(稱之為最多 5,000 條記錄,每條記錄 3 個(gè)字段).
  • 僅僅使用通配符來處理所有可能的拼寫錯(cuò)誤似乎不合邏輯.

有什么建議嗎?我知道用 MySQL 是不可能在本機(jī)上做的,但是由于數(shù)據(jù)集非常有限,我想保持它相對(duì)簡(jiǎn)單......也許是一個(gè)可以獲取all 來自數(shù)據(jù)庫(kù)的記錄,使用某種比較算法,并返回相似記錄的 ID?

Any suggestions? I know it isn't going to be possible to do natively with MySQL, but since the data set is so limited, I'd like to keep it relatively simple... perhaps a PHP class that gets all of the records from the DB, uses some sort of comparison algorithm, and returns the IDs of the similar records?

謝謝,杰森

推薦答案

Razzie 的回答(或使用 Damerau–Levenshtein) 根據(jù)與搜索關(guān)鍵字的接近程度對(duì)候選匹配列表進(jìn)行排名.(注意:如果鍵是12 Main St",則13 Main St"與12 Moin St"的打字距離相同,但您可能希望將其排在低位甚至排除它,如 11 和 22 Main St等)

Razzie's answer (or using Damerau–Levenshtein) ranks a list of candidates matches according to their closeness to the search key. (Take care: if the key is "12 Main St" then "13 Main St" has the same typing distance as "12 Moin St" but you might want to rank it low or even exclude it, as with 11 and 22 Main St etc.)

但是你如何選擇一個(gè)規(guī)模可控的候選人名單來進(jìn)行排名?

But how do you select a list of candidates of a manageable size to rank?

一種方法是為您要搜索的字符串中的每個(gè)單詞計(jì)算變音素值(或值,使用雙變音素).使用包含原始字符串的行的 id 將這些變音符中的每一個(gè)保存在另一個(gè)表中.然后,您可以使用 LIKE 'key%' 快速搜索這些變音位值,其中 key 是搜索文本中單詞的變音位.

One way is to compute the metaphone value (or values, using double-metaphone) for each word in the strings your going to search. Save each of these metaphones in another table with the id of the row containing the original string. You can then search these metaphone values quickly with LIKE 'key%' where key is the metaphone of a word from the search text.

在這個(gè)主題上查看建議的答案.它非常簡(jiǎn)潔,對(duì)于不是很大的 DB 應(yīng)該可以很好地工作.

Check out the suggested answer on this thread. It's quite neat and should work nicely for DBs that aren't huge.

這篇關(guān)于PHP/MySQL 小規(guī)模模糊搜索的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動(dòng)填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 日本免费小视频 | www.欧美.com | 97超碰站 | 国产乱码精品1区2区3区 | 中文字幕在线免费观看 | 爱综合 | 免费成人在线网站 | 国产日韩欧美二区 | 一区二区三区免费在线观看 | 成人亚洲网站 | 国产福利在线视频 | 成年人免费在线视频 | 国产美女一区二区 | 久久乐国产精品 | 黄色一级大片在线观看 | 精品久久久久香蕉网 | 九九久久久 | 亚洲成人精品一区 | 欧美福利久久 | 日本三级全黄三级a | 色天堂影院 | 91精品国产乱码麻豆白嫩 | 欧美精品三区 | 日韩午夜电影在线观看 | 91久久久久久| 一区二区三区av夏目彩春 | 精区3d动漫一品二品精区 | 日韩人体在线 | 亚洲精品一区二 | 亚洲激情在线观看 | www.47久久青青 | 日韩视频在线播放 | 国产日韩精品久久 | 男女午夜激情视频 | 一区二区三区高清 | 欧美韩一区二区三区 | 久久精品网 | 日韩国产黄色片 | 国产成人综合网 | 国产黄色大片在线观看 | 日韩电影中文字幕 |