2015-05-14 35 views
0

我有兩個類索賠和索引。我在我的聲明類中有一個名爲topic的字段,它是一個字符串。我嘗試索引不使用數據庫索引列功能的主題列。但它應該通過編碼以下方法。 假設我有權利要求1,對於權利要求1的主題領域(「我愛鬆餅鬆餅」)我會做如下因素治療它索引或標記?

#1. Create an empty Dictionary with "word"=>occurrences 
#2. Create a List of the stopwords exemple stopwords = ("For","This".....etc) 
#3. Create List of the delimiters exemple delimiter_chars = ",.;:!?" 
#4. Split the Text(topic field) into words delimited by whitespace. 
#5. Remove unwanted delimiter characters adjoining words. 
#6. Remove stopwords. 
#7. Remove Duplicate 
#8. now i create multiple index object (word="love",occurences = 1,looked = 0,reference on claim 1),(word="muffins",occurences = 2,looked = 0,reference on claim 1), 

現在每當我去找爲例鬆餅看着都加字,我會將記錄移到我的數據庫中。所以我的問題是以下是這種方法好嗎?它比數據庫索引功能好嗎?有什麼可以改進的東西嗎?

回答

1

我認爲你正在尋找的東西叫做B-Tree。在你的情況下,你會在樹中使用26(或54,如果你需要區分大小寫)分支節點。這將使查找對象非常快。我認爲時間是nlogn什麼的。在節點中,您將擁有指向數組,列表,文件或其他內容中實際數據的指針。但是,除非您願意花時間爲您的應用程序編寫特定的代碼,否則最好使用Oracle,Microsoft SQL Server或MySQL等數據庫,因爲這些數據庫是專業開發和配置以獲取儘可能達到最高性能。