Here is my code to add Java map object into Lucene: Map<String, String> map = new HashMap<>(); map.put("栋", "6"); map.put("号", "202");
Fieldable fd = new Field("testMap", map.toString(), Store.YES, Index.NO); Document d = new Document(); d.add(fd); try { writer.addDocument(d); writer.commit(); } catch (Exception e) { } Unfortunately, when I search the index, all what I get is: {号=202, 栋=6}, which doesn't contain double quotes. Therefore I can't rebuild the map object with the return value. Please help. On Wed, Feb 13, 2013 at 10:46 PM, Cheng <zhoucheng2...@gmail.com> wrote: > > http://lucene.apache.org/core/4_0_0-BETA/core/org/apache/lucene/document/StringField.html > > I found StringField API here, however, it seems that StringField can't be > found and thus not compiled. > > My lucene is 3.5 > > > On Wed, Feb 13, 2013 at 4:54 AM, Ian Lea <ian....@gmail.com> wrote: > >> Assuming you mean the String representation of a Map, the same way you >> do any other String: use StringField or an analyzer that keeps the >> characters you want it to. Maybe WhitespaceAnalyzer. >> >> >> -- >> Ian. >> >> >> On Wed, Feb 13, 2013 at 1:34 AM, Cheng <zhoucheng2...@gmail.com> wrote: >> > Hi, >> > >> > How can I add field to hold a Java map object in such way that the "[", >> > "]", "," are preserved? >> > >> > Thanks! >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org >> For additional commands, e-mail: java-user-h...@lucene.apache.org >> >> >