Hello there! I trying to query for a specific document on a efficient way. My index is structured in a way where I have an id field which is a unique key for the whole index. When I'm updating/removing a document I was searching for my id using a Searcher and a TermQuery. But reading the list it seems that its a bit of overhead, using a reader.termDocs(term) would be faster.
Here's a piece of code: private void deleteFromIndex(String id){ Term term = new Term("id",id); IndexReader reader = readerManager.getIndexReader(); TermDocs termDocs = null; try { termDocs = reader.termDocs(term); while(termDocs.next()){ int index = termDocs.doc(); if(reader.document(index).get("id").equals(id)){ reader.deleteDocument(index); } } } catch (IOException e) { e.printStackTrace(); }finally{ if(termDocs != null){ try { termDocs.close(); } catch (IOException e) { e.printStackTrace(); } } } } problem is, reader is not returning any term. When I switch to query it works. My documents have all being indexed using BrazilianAnalyzer, don't know if that could be the reason. Regards -- "In a world without fences and walls, who needs Gates and Windows?"