在 ASP.NET 电子商务站点中实现 Lucene 搜索的最佳实践

发布于 2024-07-29 04:04:37 字数 192 浏览 2 评论 0原文

我的任务是在电子商务网站上设置搜索服务。 目前,它在 sql server 上使用全文索引,这并不理想,因为它很慢,而且不太灵活。

您建议我如何将其更改为 lucene? 我的意思是,我最初如何将所有数据加载到索引中,以及如何维护它? 在我的“插入产品”方法中,我是否也可以将其插入索引中?

任何信息都有很大帮助!

I've been tasked with seeting up a search service on an eCommerce site.
Currently, it uses full text indexing on sql server, which isn't ideal, as it's slow, and not all that flexible.

How would you suggest i approach changing this over to lucene?
By that, i mean, how would i initially load all the data into the indexes, and how would it be maintained? on my "insert product" methods, would i also have it insert it into the index?

any information is of great help!

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

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

发布评论

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

评论(2

无尽的现实 2024-08-05 04:04:37

我目前正在使用 Solr,它构建在 Lucene 之上,作为我的一个电子商务项目的搜索引擎。 效果很好。

http://lucene.apache.org/solr/

另外还要保持产品同步在 DB 和 Solr 之间,您可以构建自己的“清理器”或在 Solr 中实现 DataImportHandler。

http://wiki.apache.org/solr/DataImportHandler

我们构建了自己的清理器,它读取以一定的时间间隔查看数据库并检查是否有新产品或任何产品数据已更新。 这是一种蛮力方法,我希望我之前就知道 DataImportHandler。

Facet 也是 Solr 的一个非常强大的部分。 我强烈推荐使用它们。

I'm currently using Solr, which is build on top of Lucene, as the search engine for one of my e-commerce projects. It works great.

http://lucene.apache.org/solr/

Also as far as keeping the products in sync between the DB and Solr, you can either build your own "sweeper" or implement the DataImportHandler in Solr.

http://wiki.apache.org/solr/DataImportHandler

We build our own sweeper that reads a DB view at some interval and checks to see if there are new products or any product data has been updated. It's a brute force method and I wish I knew about the DataImportHandler before.

Facets are also a really powerful part of Solr. I highly recommend using them.

空心空情空意 2024-08-05 04:04:37

如果您决定使用 Lucene.NET 进行搜索,您需要执行以下操作:

  • 通过以下方式创建初始索引
    遍历你的所有记录
    并写入你想要的数据
    搜索到索引中,
  • 如果写入索引的记录和数据量使得索引很大,那么考虑将它们填充到多个索引中(这意味着您将不得不创建一个更复杂的搜索程序,因为您需要搜索每个索引并然后合并结果!!)
  • 当更新或创建产品时,
  • 如果您的网站流量很高并且有可能多个搜索同时发生,那么您需要创建一个包装器,它可以在多个重复索引(或索引集)中为您执行搜索(此处考虑单例模式),因为索引只能被访问(打开)一个一次搜索

这是一个很棒的平台。 我们最初尝试使用自由文本搜索,发现创建索引、更新和管理非常痛苦。 搜索并不比标准 SQL 搜索快多少。 它们确实在搜索查询中提供了一些灵活性...但即使如此,与 Lucene 的强大功能相比还是相形见绌!

If you do decide to use Lucene.NET for your search you need to do some of the following:

  • create your initial index by
    iterating through all your records
    and writing the data that you want
    searched into your index
  • if the amount of records and data that you are writing to your indexes makes for large indexes then consider stuffing them into multiple indexes (this means you will have to make a more complex search program as you need to search each index and then merge the results!!)
  • when a product is updated or created you need to update your index (there is a process here to create additional index parts and then merge the indexes)
  • if you have a high traffic site and there is the possibility of multiple searches occurring at the exact same moment then you need to create a wrapper that can do the search for you across multiple duplicate indexs (or sets of indexes) (think singleton pattern here) as the index can only be accessed (opened) for one search at a time

This is a great platform. We initially tried to use the freetext search and found it to be a pain to create the indexes, update, and manage. The searches were not that much faster than a standard sql search. They did provide some flexibility in the search query...but even this pales in comparison to the power of Lucene!

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