FAQ
Hello all,

I'm not getting hits for queries that I think should
return hits.

Description:

I have created index with document having terms "body"
& "title" using StandardAnalyzer. Term "body" is added
to document as Field.Text("body", <text>) and Term
title is added as Field.Keyword("title", <title>).

I added a document with body have some 300 words and
title with 2 words.

Next, I searched the index with exactly same body that
I indexed and Lucene returns zero hits. I constructed
query using following different ways:

1. QueryParser.parse("body", <body-text>,
StandardAnalyzer);

2. Using PhraseQuery:

TokenStream tokenizer =
StandardAnalyzer.tokenStream(key, new
java.io.StringReader(<body-text>));
Token token;
PhraseQuery pq = new PhraseQuery();
while ((token = tokenizer.next()) != null)
pq.add(new Term("body", token.termText()));
pq.setSlop(50);

My understanding is that Lucene should return this
document as hit. Please let me know where I'm doing
wrong.

However, search on the title returns correct hit.

Any help on this would be really appreciated.

Thanks,

MP


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Search Discussions

  • Mmachado at Aug 2, 2003 at 5:35 am
    Hi M P,

    Try this:

    InputStream is = new FileInputStream(filename); where filename is the file
    to index.
    ----
    ---
    ---
    doc.add(Field.Text("body", (Reader) new InputStreamReader(is)));


    Michel
    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 5:25 AM
    To: lucene-user@jakarta.apache.org
    Subject: Problem in getting hits

    Hello all,

    I'm not getting hits for queries that I think should
    return hits.

    Description:

    I have created index with document having terms "body"
    & "title" using StandardAnalyzer. Term "body" is added
    to document as Field.Text("body", <text>) and Term
    title is added as Field.Keyword("title", <title>).

    I added a document with body have some 300 words and
    title with 2 words.

    Next, I searched the index with exactly same body that
    I indexed and Lucene returns zero hits. I constructed
    query using following different ways:

    1. QueryParser.parse("body", <body-text>,
    StandardAnalyzer);

    2. Using PhraseQuery:

    TokenStream tokenizer =
    StandardAnalyzer.tokenStream(key, new
    java.io.StringReader(<body-text>));
    Token token;
    PhraseQuery pq = new PhraseQuery();
    while ((token = tokenizer.next()) != null)
    pq.add(new Term("body", token.termText()));
    pq.setSlop(50);

    My understanding is that Lucene should return this
    document as hit. Please let me know where I'm doing
    wrong.

    However, search on the title returns correct hit.

    Any help on this would be really appreciated.

    Thanks,

    MP


    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-user-help@jakarta.apache.org
  • M P at Aug 2, 2003 at 5:54 am
    Hi Michel,

    I re-indexed the document as you mentioned:

    doc.add(Field.text("body", new
    java.io.StringReader(<body-text>);

    But, I'm still getting zero hits.

    Thanks,
    MP.

    --- MMachado@LEVI.com wrote:

    Hi M P,

    Try this:

    InputStream is = new FileInputStream(filename);
    where filename is the file
    to index.
    ----
    ---
    ---
    doc.add(Field.Text("body", (Reader) new
    InputStreamReader(is)));


    Michel
    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 5:25 AM
    To: lucene-user@jakarta.apache.org
    Subject: Problem in getting hits

    Hello all,

    I'm not getting hits for queries that I think should
    return hits.

    Description:

    I have created index with document having terms
    "body"
    & "title" using StandardAnalyzer. Term "body" is
    added
    to document as Field.Text("body", <text>) and Term
    title is added as Field.Keyword("title", <title>).

    I added a document with body have some 300 words and
    title with 2 words.

    Next, I searched the index with exactly same body
    that
    I indexed and Lucene returns zero hits. I
    constructed
    query using following different ways:

    1. QueryParser.parse("body", <body-text>,
    StandardAnalyzer);

    2. Using PhraseQuery:

    TokenStream tokenizer =
    StandardAnalyzer.tokenStream(key, new
    java.io.StringReader(<body-text>));
    Token token;
    PhraseQuery pq = new PhraseQuery();
    while ((token = tokenizer.next()) != null)
    pq.add(new Term("body", token.termText()));
    pq.setSlop(50);

    My understanding is that Lucene should return this
    document as hit. Please let me know where I'm doing
    wrong.

    However, search on the title returns correct hit.

    Any help on this would be really appreciated.

    Thanks,

    MP


    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com

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

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

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com
  • Mmachado at Aug 2, 2003 at 7:26 am
    Hi M P,
    Is not StringReader but new InputStreamReader. Try this:

    public void indexFile(String filename) throws Exception {
    IndexWriter writer;
    writer = new IndexWriter(path, new SimpleAnalyzer(), false);

    InputStream is = new FileInputStream(filename);
    Document doc = new Document();
    doc.add(Field.UndIndexed("path", filename));
    doc.add(Field.Text("body", (Reader) new InputStreamReader(is)));

    writer.addDocument(doc);
    is.close();
    writer.close();
    }

    Good Luck
    Michel

    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 7:54 AM
    To: Lucene Users List
    Subject: RE: Problem in getting hits

    Hi Michel,

    I re-indexed the document as you mentioned:

    doc.add(Field.text("body", new
    java.io.StringReader(<body-text>);

    But, I'm still getting zero hits.

    Thanks,
    MP.

    --- MMachado@LEVI.com wrote:

    Hi M P,

    Try this:

    InputStream is = new FileInputStream(filename);
    where filename is the file
    to index.
    ----
    ---
    ---
    doc.add(Field.Text("body", (Reader) new
    InputStreamReader(is)));


    Michel
    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 5:25 AM
    To: lucene-user@jakarta.apache.org
    Subject: Problem in getting hits

    Hello all,

    I'm not getting hits for queries that I think should
    return hits.

    Description:

    I have created index with document having terms
    "body"
    & "title" using StandardAnalyzer. Term "body" is
    added
    to document as Field.Text("body", <text>) and Term
    title is added as Field.Keyword("title", <title>).

    I added a document with body have some 300 words and
    title with 2 words.

    Next, I searched the index with exactly same body
    that
    I indexed and Lucene returns zero hits. I
    constructed
    query using following different ways:

    1. QueryParser.parse("body", <body-text>,
    StandardAnalyzer);

    2. Using PhraseQuery:

    TokenStream tokenizer =
    StandardAnalyzer.tokenStream(key, new
    java.io.StringReader(<body-text>));
    Token token;
    PhraseQuery pq = new PhraseQuery();
    while ((token = tokenizer.next()) != null)
    pq.add(new Term("body", token.termText()));
    pq.setSlop(50);

    My understanding is that Lucene should return this
    document as hit. Please let me know where I'm doing
    wrong.

    However, search on the title returns correct hit.

    Any help on this would be really appreciated.

    Thanks,

    MP


    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com

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

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

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail: lucene-user-help@jakarta.apache.org
  • M P at Aug 2, 2003 at 4:20 pm
    Hi,

    I'm still getting no hits with the code that you sent.

    Thanks,

    Kishore.

    --- MMachado@LEVI.com wrote:
    Hi M P,
    Is not StringReader but new InputStreamReader. Try
    this:

    public void indexFile(String filename) throws
    Exception {
    IndexWriter writer;
    writer = new IndexWriter(path, new
    SimpleAnalyzer(), false);

    InputStream is = new FileInputStream(filename);
    Document doc = new Document();
    doc.add(Field.UndIndexed("path", filename));
    doc.add(Field.Text("body", (Reader) new
    InputStreamReader(is)));

    writer.addDocument(doc);
    is.close();
    writer.close();
    }

    Good Luck
    Michel

    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 7:54 AM
    To: Lucene Users List
    Subject: RE: Problem in getting hits

    Hi Michel,

    I re-indexed the document as you mentioned:

    doc.add(Field.text("body", new
    java.io.StringReader(<body-text>);

    But, I'm still getting zero hits.

    Thanks,
    MP.

    --- MMachado@LEVI.com wrote:

    Hi M P,

    Try this:

    InputStream is = new FileInputStream(filename);
    where filename is the file
    to index.
    ----
    ---
    ---
    doc.add(Field.Text("body", (Reader) new
    InputStreamReader(is)));


    Michel
    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 5:25 AM
    To: lucene-user@jakarta.apache.org
    Subject: Problem in getting hits

    Hello all,

    I'm not getting hits for queries that I think should
    return hits.

    Description:

    I have created index with document having terms
    "body"
    & "title" using StandardAnalyzer. Term "body" is
    added
    to document as Field.Text("body", <text>) and Term
    title is added as Field.Keyword("title", <title>).
    I added a document with body have some 300 words and
    title with 2 words.

    Next, I searched the index with exactly same body
    that
    I indexed and Lucene returns zero hits. I
    constructed
    query using following different ways:

    1. QueryParser.parse("body", <body-text>,
    StandardAnalyzer);

    2. Using PhraseQuery:

    TokenStream tokenizer =
    StandardAnalyzer.tokenStream(key, new
    java.io.StringReader(<body-text>));
    Token token;
    PhraseQuery pq = new PhraseQuery();
    while ((token = tokenizer.next()) != null)
    pq.add(new Term("body", token.termText()));
    pq.setSlop(50);

    My understanding is that Lucene should return this
    document as hit. Please let me know where I'm doing
    wrong.

    However, search on the title returns correct hit.

    Any help on this would be really appreciated.

    Thanks,

    MP


    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com
    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail:
    lucene-user-help@jakarta.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail:
    lucene-user-help@jakarta.apache.org

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com

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

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

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com
  • M P at Aug 3, 2003 at 6:12 pm
    Hi,

    I would really appreciate if anyone could please send
    me a sample code on how to query using QueryParser and
    PhraseQuery for documents with two fields "title" &
    "body" indexed as Field.Keyword & Field.Text
    respectively.

    Thanks,

    Kishore.

    --- M P wrote:
    Hi,

    I'm still getting no hits with the code that you
    sent.

    Thanks,

    Kishore.

    --- MMachado@LEVI.com wrote:
    Hi M P,
    Is not StringReader but new InputStreamReader. Try
    this:

    public void indexFile(String filename) throws
    Exception {
    IndexWriter writer;
    writer = new IndexWriter(path, new
    SimpleAnalyzer(), false);

    InputStream is = new FileInputStream(filename);
    Document doc = new Document();
    doc.add(Field.UndIndexed("path", filename));
    doc.add(Field.Text("body", (Reader) new
    InputStreamReader(is)));

    writer.addDocument(doc);
    is.close();
    writer.close();
    }

    Good Luck
    Michel

    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 7:54 AM
    To: Lucene Users List
    Subject: RE: Problem in getting hits

    Hi Michel,

    I re-indexed the document as you mentioned:

    doc.add(Field.text("body", new
    java.io.StringReader(<body-text>);

    But, I'm still getting zero hits.

    Thanks,
    MP.

    --- MMachado@LEVI.com wrote:

    Hi M P,

    Try this:

    InputStream is = new FileInputStream(filename);
    where filename is the file
    to index.
    ----
    ---
    ---
    doc.add(Field.Text("body", (Reader) new
    InputStreamReader(is)));


    Michel
    -----Original Message-----
    From: M P
    Sent: Saturday, August 02, 2003 5:25 AM
    To: lucene-user@jakarta.apache.org
    Subject: Problem in getting hits

    Hello all,

    I'm not getting hits for queries that I think should
    return hits.

    Description:

    I have created index with document having terms
    "body"
    & "title" using StandardAnalyzer. Term "body" is
    added
    to document as Field.Text("body", <text>) and
    Term
    title is added as Field.Keyword("title",
    <title>).
    I added a document with body have some 300 words and
    title with 2 words.

    Next, I searched the index with exactly same
    body
    that
    I indexed and Lucene returns zero hits. I
    constructed
    query using following different ways:

    1. QueryParser.parse("body", <body-text>,
    StandardAnalyzer);

    2. Using PhraseQuery:

    TokenStream tokenizer =
    StandardAnalyzer.tokenStream(key, new
    java.io.StringReader(<body-text>));
    Token token;
    PhraseQuery pq = new PhraseQuery();
    while ((token = tokenizer.next()) != null)
    pq.add(new Term("body", token.termText()));
    pq.setSlop(50);

    My understanding is that Lucene should return
    this
    document as hit. Please let me know where I'm doing
    wrong.

    However, search on the title returns correct
    hit.
    Any help on this would be really appreciated.

    Thanks,

    MP


    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com
    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail:
    lucene-user-help@jakarta.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail:
    lucene-user-help@jakarta.apache.org

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com
    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail:
    lucene-user-help@jakarta.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    lucene-user-unsubscribe@jakarta.apache.org
    For additional commands, e-mail:
    lucene-user-help@jakarta.apache.org

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site
    design software
    http://sitebuilder.yahoo.com

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

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedAug 2, '03 at 3:24a
activeAug 3, '03 at 6:12p
posts6
users2
websitelucene.apache.org

2 users in discussion

M P: 4 posts Mmachado: 2 posts

People

Translate

site design / logo © 2022 Grokbase