A couple of questions: 1> I assume by "not returning any docs" you mean that you never get into your while loop. Is that true? 2> I'm a little suspicious of the field labeled "id" and whether it's at all possible that this is getting confused with the internal Lucene doc ID. This is a wild shot in the dark influenced by the fact that I'm working with Groovy where property access is equivalent to get..... 3> What is the form of your unique key? If it's all numeric I don't see a problem, but if it has any non-numeric characters in it, then your analyzer will probably lower-case the term wheres your term constructor won't. Which would also explain why searching would work.
If none of this is remotely helpful, could you post a few examples of keys that work and those that don't? Best Erick On Fri, Jun 20, 2008 at 12:12 PM, Vinicius Carvalho < [EMAIL PROTECTED]> wrote: > 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?" >