Yeah but if it happens that for a certain document field1 has only one value and in that case I can't know it is intended as a multiple. in that case adds.size() would be == 1 and it would look as normal field.
What i need is to mark that field is intended to be multiple no matter if it contains 1 value or 10. I need this because my serach results are passed as JSON to other consumers and i have to tell them what's the structure. Erick Erickson wrote: > > No, no, no... > > Say you have the following > Document doc = new Document() > doc.add("field1", "stuff", blah, blah) > doc.add("field1", "more stuff", blah, blah) > doc.add("field1", "stuff and nonsense", blah, blah) > IndexWriter.addDocument(doc) > > > > > Now, in your search code that document comes up as a hit and you have > Field[] adds = doc.getFields("field1"); > > > adds.size() should == 3 > > whenever adds.size() > 1, you can know it has multiple entries.... > > I wasn't suggesting that you ever add empty fields, and I don't think an > empty > add would even compile. > > Best > [EMAIL PROTECTED] > > > On Fri, Oct 24, 2008 at 3:38 PM, agatone <[EMAIL PROTECTED]> wrote: > >> >> That sounds like abuse of Document.add() :) >> Ok, so adding first one extra "empty" value for every field i wish to >> mark >> as multi. >> Well if that ain't so wrong, I'll use that :) >> >> Ty >> >> >> >> >> Erick Erickson wrote: >> > >> > I *think* what you're looking for is Document.getFields(String field), >> > which returns a list corresponding to every Document.add() you did >> > originally. >> > >> > Alternatively, you could always index a companion field that had the >> > count of times you called Document.add() on a particular field..... >> > >> > Best >> > Erick >> > >> > On Fri, Oct 24, 2008 at 11:36 AM, agatone <[EMAIL PROTECTED]> wrote: >> > >> >> >> >> Hello, >> >> >> >> I know I can store multiple values under same field and I can later >> >> retrieve >> >> all those values. But the problem I have is a bit structure related. >> When >> >> I'm reading those fields (that usually have more than one value) it >> >> happens >> >> that it has only one value and I cannot know if that field is meant to >> >> have >> >> multiple values. >> >> >> >> Is there a way (at indexing (creating fields)) to set that certain >> field >> >> is >> >> meant for multiple values, so that later when I'm searching and I get >> >> document/s hit, I can get from each field in it how to represent the >> hit. >> >> >> >> Thank you. >> >> >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/Multiple-values-in-field-tp20152411p20152411.html >> >> Sent from the Lucene - Java Users mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/Multiple-values-in-field-tp20152411p20156607.html >> Sent from the Lucene - Java Users mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > -- View this message in context: http://www.nabble.com/Multiple-values-in-field-tp20152411p20162152.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]