FAQ
Hi ! I am newbie in lucene, and i have some problems to create a
simple code to query a text file collection.

My code is this (http://pastebin.com/HqrbBPtp), but does not works.
What is Wrong?

Thanks,
Celso.

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

Search Discussions

  • Uwe Schindler at Nov 5, 2010 at 7:37 am
    The default field of query parser is wrong:
    QueryParser parser = new QueryParser(Version.LUCENE_30, "computer",
    analyzer);

    You haven't indexed a field with name "computer". Your query string does not
    override the field, so your query is in fact "computer:computer".

    A note: It is not recommended to instantiate TopScoreDocCollector directly
    for such search cases, just use the IndexSearcher method that returns
    TopDocs!

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de
    -----Original Message-----
    From: Celso Fontes
    Sent: Friday, November 05, 2010 3:34 AM
    To: java-user@lucene.apache.org
    Subject: How index and search text files in Lucene 3.0.2 ?

    Hi ! I am newbie in lucene, and i have some problems to create a simple code
    to query a text file collection.

    My code is this (http://pastebin.com/HqrbBPtp), but does not works.
    What is Wrong?

    Thanks,
    Celso.

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


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Celso Fontes at Nov 5, 2010 at 4:01 pm
    Thanks Uwe, its works with:

    QueryParser parser = new QueryParser(Version.LUCENE_30,
    "content:computer", analyzer);
    Query query = parser.parse("content:computer");

    But, if i need get results like google in a query like "What is the
    role of PrnP in mad cow disease?"

    Thanks
    CElso.

    2010/11/5 Uwe Schindler <uwe@thetaphi.de>:
    The default field of query parser is wrong:
    QueryParser parser = new QueryParser(Version.LUCENE_30, "computer",
    analyzer);

    You haven't indexed a field with name "computer". Your query string does not
    override the field, so your query is in fact "computer:computer".

    A note: It is not recommended to instantiate TopScoreDocCollector directly
    for such search cases, just use the IndexSearcher method that returns
    TopDocs!

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de
    -----Original Message-----
    From: Celso Fontes
    Sent: Friday, November 05, 2010 3:34 AM
    To: java-user@lucene.apache.org
    Subject: How index and search text files in Lucene 3.0.2 ?

    Hi ! I am newbie in lucene, and i have some problems to create a simple code
    to query a text file collection.

    My code is this (http://pastebin.com/HqrbBPtp), but does not works.
    What is Wrong?

    Thanks,
    Celso.

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


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Uwe Schindler at Nov 5, 2010 at 4:06 pm
    Hi Celso,

    just a note, your code makes no sense:

    In the constructor of QueryParser you have to give the default field, e.g.
    "content" only - With parse() you have to give the query string (which can
    contain a field name or not): "computer" or alternatively "content:computer"
    (which returns equal results because the default field from the ctor is
    content:

    QueryParser parser = new QueryParser(Version.LUCENE_30, "content",
    analyzer);
    Query query = parser.parse("computer");

    or:

    Query query = parser.parse("content:computer");

    Uwe

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de

    -----Original Message-----
    From: Celso Fontes
    Sent: Friday, November 05, 2010 5:01 PM
    To: java-user@lucene.apache.org
    Subject: Re: How index and search text files in Lucene 3.0.2 ?

    Thanks Uwe, its works with:

    QueryParser parser = new QueryParser(Version.LUCENE_30,
    "content:computer", analyzer);
    Query query = parser.parse("content:computer");

    But, if i need get results like google in a query like "What is the role
    of PrnP in
    mad cow disease?"

    Thanks
    CElso.

    2010/11/5 Uwe Schindler <uwe@thetaphi.de>:
    The default field of query parser is wrong:
    QueryParser parser = new QueryParser(Version.LUCENE_30, "computer",
    analyzer);

    You haven't indexed a field with name "computer". Your query string
    does not override the field, so your query is in fact
    "computer:computer".
    A note: It is not recommended to instantiate TopScoreDocCollector
    directly for such search cases, just use the IndexSearcher method that
    returns TopDocs!

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de
    -----Original Message-----
    From: Celso Fontes
    Sent: Friday, November 05, 2010 3:34 AM
    To: java-user@lucene.apache.org
    Subject: How index and search text files in Lucene 3.0.2 ?

    Hi ! I am newbie in lucene, and i have some problems to create a
    simple code
    to query a text file collection.

    My code is this (http://pastebin.com/HqrbBPtp), but does not works.
    What is Wrong?

    Thanks,
    Celso.

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


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


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Celso Fontes at Nov 5, 2010 at 4:08 pm
    thanks !

    2010/11/5 Uwe Schindler <uwe@thetaphi.de>
    Hi Celso,

    just a note, your code makes no sense:

    In the constructor of QueryParser you have to give the default field, e.g.
    "content" only - With parse() you have to give the query string (which can
    contain a field name or not): "computer" or alternatively
    "content:computer"
    (which returns equal results because the default field from the ctor is
    content:

    QueryParser parser = new QueryParser(Version.LUCENE_30, "content",
    analyzer);
    Query query = parser.parse("computer");

    or:

    Query query = parser.parse("content:computer");

    Uwe

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de

    -----Original Message-----
    From: Celso Fontes
    Sent: Friday, November 05, 2010 5:01 PM
    To: java-user@lucene.apache.org
    Subject: Re: How index and search text files in Lucene 3.0.2 ?

    Thanks Uwe, its works with:

    QueryParser parser = new QueryParser(Version.LUCENE_30,
    "content:computer", analyzer);
    Query query = parser.parse("content:computer");

    But, if i need get results like google in a query like "What is the role
    of PrnP in
    mad cow disease?"

    Thanks
    CElso.

    2010/11/5 Uwe Schindler <uwe@thetaphi.de>:
    The default field of query parser is wrong:
    QueryParser parser = new QueryParser(Version.LUCENE_30, "computer",
    analyzer);

    You haven't indexed a field with name "computer". Your query string
    does not override the field, so your query is in fact
    "computer:computer".
    A note: It is not recommended to instantiate TopScoreDocCollector
    directly for such search cases, just use the IndexSearcher method that
    returns TopDocs!

    -----
    Uwe Schindler
    H.-H.-Meier-Allee 63, D-28213 Bremen
    http://www.thetaphi.de
    eMail: uwe@thetaphi.de
    -----Original Message-----
    From: Celso Fontes
    Sent: Friday, November 05, 2010 3:34 AM
    To: java-user@lucene.apache.org
    Subject: How index and search text files in Lucene 3.0.2 ?

    Hi ! I am newbie in lucene, and i have some problems to create a
    simple code
    to query a text file collection.

    My code is this (http://pastebin.com/HqrbBPtp), but does not works.
    What is Wrong?

    Thanks,
    Celso.

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


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


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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedNov 5, '10 at 2:34a
activeNov 5, '10 at 4:08p
posts5
users2
websitelucene.apache.org

2 users in discussion

Celso Fontes: 3 posts Uwe Schindler: 2 posts

People

Translate

site design / logo © 2022 Grokbase