如何在 SQL Server 中搜索 varbinary 字段?

发布于 2024-08-22 05:32:26 字数 245 浏览 2 评论 0原文

我有一个应用程序,允许用户上传文件,主要是 PDF 和 Word 文档。这些文件存储在数据库的 varbinary 字段中。无论用户如何通过 Web 或 Windows 窗体应用程序或任何其他表示层访问应用程序,我都需要让这些文件可用。

有没有办法搜索这些字段的原始文本内容?例如,如果我上传一份简历,我希望用户能够搜索 C# 并能够在 varbinary 字段的内容中查找指定的文本。

另外,如果有更好的策略来处理这个问题,我对此持开放态度。

I have an application where I allow users to upload files, mainly PDF and Word documents. These files are stored in a varbinary field in the database. For what it is worth, I need to have these files available regardless of how the user is accessing the application, via Web or Windows Forms application or any other Presentation layer.

Is there a way to search the raw text contents of these fields? For example, if I upload a resume, I would like the user to be able to search C# and be able to look in the contents of varbinary field for the specified text.

Also, if there is a better strategy for handling this, I am open to it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌酱 2024-08-29 05:32:26

我想说,使用 SQL Server 对于这项工作(搜索方面)来说是错误的工具,因为它无法本机解析存储在二进制文档中的文本。

我建议查看类似 Lucene.NET (Lucene 搜索的 .NET 端口)引擎...最初是用 Java 编写的),这将允许您在上传文档后轻松搜索它们。

您应该能够构建一个解决方案,允许您将文档存储保留在 SQL Server 中,但使用 Lucene.NET 来索引和搜索存储在其中的文档。

I would say that using SQL Server is the wrong tool for the job (search-wise) as it can't natively parse through the text stored in a binary document.

I suggest looking in to something like Lucene.NET (the .NET port of the Lucene Search Engine...originally written in Java) which will allow you to easily search through your documents after they've been uploaded.

You should be able to architect a solution that allows you to retain your document storage in SQL Server but use Lucene.NET to index and search the documents that you have stored there.

_畞蕅 2024-08-29 05:32:26

您需要一层代码来提取类型并了解格式。对于 SQL 来说,它只是原始数据

You need a layer of some code to extract the type and have knowledge of the format. To SQL, it's just raw data

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文