Lucene.Net : An overview1. Initialize Directory and IndexWriter
The initial step is introducing the Directory and the IndexWriter. In a web application, as Subtext, this is doubtlessly done in the application startup and afterward, the occurrence put away in a worldwide variable some place (or got to through a Singleton) since stand out Writer can read the Dictionary in the meantime.
What's more, when you make the IndexWriter you can supply the analyzer that will be utilized as a matter of course to record all the content.
2. Add Documents to the Index
Every record is made by different Fields. You need to make a Document with every one of the Fields that must be recorded furthermore the ones you require keeping in mind the end goal to interface the outcome to the genuine archive that is being filed (for instance the id of the post).
Also, once made the Document, you need to add it to the Directory with the IndexWriter.
Now, you could either include more reports or close the IndexWriter. The file will be spared to the Directory and can be re-opened later to add more Documents or to perform questions on in.
3. Create the Query
When you have every one of your records in the file, it's an ideal opportunity to do a few questions.
You can make the question either through the QueryParser or make a Query protest straightforwardly by means of API.
4. Pass the Query to the IndexSearcher
Furthermore, once you have the Query object you need to pass it to the Search strategy for an IndexSearcher.
One admonition are that the IndexSearcher sees the record just at the point it was at the time it was opened. So as to hunt over the latest arrangement of reports you need to re-open the IndexSearcher. Be that as it may, re-opening requires some investment and assets, so in a web application, you might need to store it some way or another and re-open it eventally.
5. Iterates over the outcomes
The Search technique gives back the outcomes, inside a Hit item, which contains every one of the records that match the question, requested by Score, which is an exceptionally complex math equation that ought to let you know how much the report found is identified with your inquiry. For more data allude to Lucene site: Scoring.
6. Close everything
Also, once you are finished with everything, close the IndexWriter, IndexSearcher, and the Directory object. In a web application, this is normally performed in the application shutdown event.
Well, at a certain point it can be clearly seen that Lucene.NET strives to be better.