You can freely add the same field (with different text) to a doc. For instance Document doc = new Document(); doc.add("field", "this is the first"); doc.add("field", "starting the second "); IndexWriter.addDocument(doc)
is functionally the same as Document doc = new Document(); doc.add("field", "this is the first starting the second"); IndexWriter.addDocument(doc) with one subtle difference. The first version will add whatever is returned from Analyzer.getPositionIncrementGap to the term position of the first token in adds 2-n. That is, say getPositionIncrementGap returned 100. Then the token "first" would have position 3 and "starting" would have position 103 (I may be off by one on both these, but you get the idea). The default return is 1, so if you do nothing special, the two calls will be identical. Why would you return something other than 1 from getPositionIncrementGap? Well, if you want to dance fancy and, say, NOT span across the two lines above for, say, SpanNear clauses, you could return a large number that was bigger than the max allowable span. Best Erick On Tue, Apr 15, 2008 at 10:26 AM, AJ Weber <[EMAIL PROTECTED]> wrote: > I'm curious how people are building the "all" Field (for searching "all of > the terms at once"). > > I understand using store=NO, Index=Tokenized is generally the way to add > the field, but what if I need to basically use multiple classes to build my > Document before adding it to the index (keeping things modular and > reusable)? > > If one class adds the Field (i.e. doc.add("all", sCurrentString, > Field.Store.NO, Field.Index.TOKENIZED) ), then I pass the document ("doc" > in this example) to another class, how do I basically concat any additional > field-values/strings to the existing text-Field? This is all before the > Document is added to the index in the first-place. > > I'm concerned that doing a doc.get("all") and then adding it back to the > doc with the additional string will result in two fields of the name "all" > (I seem to have read this is the functionality somewhere)??? > > Thanks in advance! > -AJ