这个问题看起来很简单,但我不确定我是否能以最有效的方式处理我的问题。
我使用的是MongoDB 3.2.4版。我有一个只有一个字段Html
的集合(除了id,ofc)。共有8,821,851个文件。每个文档都包含一个html文件,其中包含大约20页的文本(从网上抓取的报告几乎相同)。
我想做一些简单的查询来搜索包含某些文本的文档(例如,ID编号为" 5555888"或名称" John")。我尝试过一些简单的查询:
db.collection.find(
{"Html" : /.*93335620125.*/}
)
db.collection.find(
{"Html" : /93335620125/}
)
db.zk1.findOne(
{"Html" : {$regex : "John"}
)
但不幸的是,它们都非常慢。有时我甚至不会在我的IDEA中获得任何结果(我使用IntelliJ IDEA 2016.1.1)。
有人可以推荐一些更有效的方法来查询大量带有html标签的大杂乱文本文件吗?
修改
我举一个文件的例子(部分文件):
"<a name=\"JR_PAGE_ANCHOR_0_1\"></a>\n<table style=\"width: 595px; border-collapse: collapse; empty-cells: show\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"white\">\n<tr>\n <td style=\"width: 20px; height: 1px;\"></td>\n <td style=\"width: 40px; height: 1px;\"></td>\n <td style=\"width: 20px; height: 1px;\"></td>\n <td style=\"width: 22px; height: 1px;\"></td>\n <td style=\"width: 108px; height: 1px;\"></td>\n <td style=\"width: 88px; height: 1px;\"></td>\n <td style=\"width: 117px; height: 1px;\"></td>\n <td style=\"width: 80px; height: 1px;\"></td>\n <td style=\"width: 79px; height: 1px;\"></td>\n <td style=\"width: 1px; height: 1px;\"></td>\n <td style=\"width: 20px; height: 1px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td colspan=\"11\" style=\"width: 595px; height: 20px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td colspan=\"2\" style=\"width: 60px; height: 46px;\"></td>\n <td colspan=\"2\"><img src=\"/servlets/PublicReportServlet?_image_=img_0_0_9\" style=\"height: 46px\" alt=\"\"/></td>\n <td colspan=\"6\" style=\"text-align: right;\"><span style=\"font-family: Times New Roman; color: #000000; font-size: 18.0px; font-weight: bold;\">NESLUŽBENA KOPIJA</span></td>\n <td style=\"width: 20px; height: 46px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td style=\"width: 20px; height: 12px;\"></td>\n <td colspan=\"9\"><span style=\"font-family: Times New Roman; color: #000000; font-size: 10.0px; font-weight: bold;\">REPUBLIKA HRVATSKA</span></td>\n <td style=\"width: 20px; height: 12px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td colspan=\"11\" style=\"width: 595px; height: 4px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td style=\"width: 20px; height: 12px;\"></td>\n <td colspan=\"9\"><span style=\"font-family: Times New Roman; color: #000000; font-size: 10.0px; font-weight: bold;\">Općinski sud u Novom Zagrebu</span></td>\n <td style=\"width: 20px; height: 12px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td style=\"width: 20px; height: 12px;\"></td>\n <td colspan=\"9\"><span style=\"font-family: Times New Roman; color: #000000; font-size: 10.0px; font-weight: bold;\">ZEMLJIŠNOKNJIŽNI ODJEL NOVI ZAGREB</span></td>\n <td style=\"width: 20px; height: 12px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td style=\"width: 20px; height: 12px;\"></td>\n <td colspan=\"4\" style=\"border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; \"><span style=\"font-family: Times New Roman; color: #000000; font-size: 10.0px; font-weight: bold;\">Stanje na dan: 19.06.2016 23:05</span></td>\n <td colspan=\"5\" style=\"border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #000000; text-align: right;\"><span style=\"font-family: Times New Roman; color: #000000; font-size: 10.0px;\">Verificirani poduložak</span></td>\n <td style=\"width: 20px; height: 12px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td style=\"width: 20px; height: 12px;\"></td>\n <td colspan=\"9\"></td>\n <td style=\"width: 20px; height: 12px;\"></td>\n</tr>\n<tr valign=\"top\">\n <td style=\"width: