Lucene.Net Best Practices

后端 未结 5 2070
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 05:38

What are the best practices in using Lucene.Net? or where can I find a good lucene.net usage sample?

5条回答
  •  不思量自难忘°
    2021-01-30 06:02

    We frequently use Lucene.NET when the data is huge and needs to have super fast response times for reading. We generally stick the data in that we need to search as well as the key to allow us to map our results back to the database table that has the remaining details. This then allows us to search for a user (in our case) checking for their past participation. This is not just a username search but a search that iterates over various details trying to find if there are any other instances of that user (albeit in a different form). An example of this, we look for the users ID (from one system), their ID from another system, perhaps an ID from a suppliers system, a flash cookie GUID, a sites cookie GUID, etc. And as we find one identifier we look for other instances of that identifier for other instances of users. This allow us to dedup the users entry into one of many systems (as their participation in any system is only allowed once per 24 hours). In SQL this alogrithm (which I was vague about) would take forever! In Lucene.NET it takes less than a second. Lucene has many more search possibilities than SQL Server does. The thing that it sucks at is writing to or updating your index. This is usually done as a job...all at once. However, if you need to write to the index updating it in real time you need to write some clever code to insure that it is written to in a locked fashion (think queueing with singleton) or your code will overlap and explode!

    I cover the usage of Lucene.NET in my book (ASP.NET Social Networking) and you can find lots of help here.

提交回复
热议问题