lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: cannot retrieve the values of a field is not stored in the index
Date Fri, 05 Jun 2009 13:30:43 GMT
Enumerating terms will be inefficient compared to getting the stored field.I'd
try soring the fields first until and unless you can demonstrate a problem.
BTW, if you're not going to *search* on the field, there's no reason to
index
it at all.

Why do think you don't want to store the paths? How big is your index?
Are you running into any performance issues?

Best
Erick

On Fri, Jun 5, 2009 at 7:14 AM, Ian Lea <ian.lea@gmail.com> wrote:

> You can't get at the field values from the document hits.
> Field.Store.NO means it isn't stored and what isn't there can't be
> retrieved.
>
> But you should be able to get at the indexed paths via a TermEnum.
> Something like this
>
>        IndexReader reader = IndexReader.open(...);
>        String field = "path".intern();
>        Term st = new Term("path", "");
>        TermEnum te = reader.terms(st);
>        while (true) {
>            Term t = te.term();
>            if (t == null || t.field() != field) {
>                break;
>            }
>            System.out.println(t.text());
>            if (!te.next()) {
>                break;
>            }
>        }
>    }
>
>
> --
> Ian.
>
>
> On Fri, Jun 5, 2009 at 1:18 AM, Alex Steward<alex_lucene@yahoo.com> wrote:
> >
> >
> > Hi,
> >
> >   Is there a way I can retrieve the value of a field that is not stored
> in the Index?
> >
> >
> > private static void indexFile(IndexWriter writer, File f)
> >     throws IOException {
> >
> >     if (f.isHidden() || !f.exists() || !f.canRead()) {
> >       return;
> >     }
> >
> >     System.out.println("Indexing " + f.getCanonicalPath());
> >
> >     Document doc = new Document();
> >
> >     // add contents of file
> >     FileReader fr = new FileReader(f);
> >
> >     doc.add(new Field("contents", fr));
> >
> >     //adding second field which contains the path of the file
> >     doc.add(new Field("path", f.getCanonicalPath(),
> >                 Field.Store.NO,
> >                 Field.Index.NOT_ANALYZED));
> > }
> >
> > Is there a way I can access the value of the field "path" from the
> document hits?
> >
> > Thanks,
> > a
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message