Lucene is an open source search engine library written in Java. It provides full text search functionality and supports indexing, searching, sorting and filtering of documents. Lucene creates an inverted index of terms extracted from documents, which allows for fast searching. The index is divided into segments for improved performance. Documents are indexed by adding them to memory first before being flushed to segments. Updates and deletes are handled by marking documents as deleted rather than removing them. Scoring is based on term frequency and inverse document frequency to determine relevance to a query.