lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Text is not indexed when passed as a StringReader
Date Fri, 16 Sep 2005 20:29:34 GMT

I think you may be having another problem somewhere, usinga StringReader
works just fine for me (in fact: when you create a field with
a plain String, it is wrapped in a StringReader to pass to
your analyzer.

Note the following demo works just fine...

    public static void main(String[] args) throws Exception {
        RAMDirectory index = new RAMDirectory();
        IndexWriter writer = new IndexWriter(index,
                                             new WhitespaceAnalyzer(),
                                             true);
        Document doc = new Document();
        doc.add(Field.Text("foo", new StringReader("a b c d")));
        writer.addDocument(doc);
        writer.close();
        IndexSearcher s = new IndexSearcher(IndexReader.open(index));
        Hits h = s.search(new TermQuery(new Term("foo","a")));
        System.out.println(h.length() == 1 ? "FOUND" : "ERROR");
    }






: Date: Sat, 17 Sep 2005 03:51:28 +0800
: From: "[ISO-8859-15] Matthias Bräuer" <newsletter@matrix-web.de>
: Reply-To: java-user@lucene.apache.org, matthew@matrix-web.de
: To: java-user@lucene.apache.org
: Subject: Text is not indexed when passed as a StringReader
:
: Hello,
:
: this question seems to have occured in the mailing list before but I
: wasn't able to find a satisfying answer. So please excuse if I'm asking
: something that has already been discussed.
:
: My problem is as follows:
: If I use the Field.Text(String,Reader) method to create an indexed, but
: unstored field and the passed in Reader happens to be a StringReader
: (e.g. when extracting Word documents using the Textmining library) the
: field is not indexed at all. That means Luke shows no terms for this
: field and, consequently, searches do not yield any result. For
: FileReaders, however, everything seems to work fine.
:
: Of course, I could just convert the reader back into a string (e.g. with
: Jakarta Commons IO - IOTools.toString()) and use the
: Unstored(String,String) method but then again it wouldn't make sense to
: use a StringReader in the first place.
:
: Thanks for your help,
: Matthias
:
:
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
: For additional commands, e-mail: java-user-help@lucene.apache.org
:



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message