FAQ
Hi,
I'm using Lucene's SpellChecker (Lucene 2.1.0) class to get suggestions.
Till now my testing server was a VMWare-Image from http://es.cohesiveft.com
http://es.cohesiveft.com (Ubuntu 8.10, Tomcat6, Java5).
Now I'm using a Debian Etch Server with Tomcat5.5 and Java6.

Code-Sample:
String indexName = indexLocation;
String queryString = null;
queryString = URLDecoder.decode(request.getParameter("q"), "UTF-8");
SpellChecker spellchecker = new
SpellChecker(FSDirectory.getDirectory(indexName));
String[] suggestions = spellchecker.suggestSimilar(queryString, 5,
IndexReader.open(indexName), "content", false);
for(int i = 0; i < suggestions.length; i++) {
out.println(suggestions[i]);
}

This worked fine on the old server, but on my new server this returns
nothing.
The index is generated by the nutch crawler, but this shouldn't be the
problem.

I've got the lucene-spellchecker-2.1.0.jar in the WEB-INF/lib/ (If I remove
it, I get the expected errormessage.)

So I don't know why I neither get results, nor an errormessage.
--
View this message in context: http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p20910159.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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

Search Discussions

  • Matthias W. at Dec 9, 2008 at 3:12 pm
    I tested it with the lucene-spellchecker-2.4.0.jar...
    Then I get the queryString as suggestion if it exists in the index. But
    there's no chance to get other suggestions neither with LevensteinDistance
    nor with JaroWinklerDistance. The setAccuracy() method has no effect on the
    result.

    I think this is because of a server misconfiguration, but I've got no idea
    whats the reason for.
    What can I do now?
    --
    View this message in context: http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p20916424.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Grant Ingersoll at Dec 10, 2008 at 3:38 pm
    So, what changed with the server?

    From the looks of your code, you're passing the same index into both
    the Spellchecker and the IndexReader. The spelling index is separate
    from the main index.

    See the example at: http://lucene.apache.org/java/2_4_0/api/contrib-spellchecker/org/apache/lucene/search/spell/SpellChecker.html

    See also my Boot Camp examples at: http://www.lucenebootcamp.com/LuceneBootCamp/training/src/test/java/com/lucenebootcamp/training/basic/ContribExamplesTest.java
    Have a look at the testSpelling code there

    HTH,
    Grant

    On Dec 9, 2008, at 2:50 AM, Matthias W. wrote:


    Hi,
    I'm using Lucene's SpellChecker (Lucene 2.1.0) class to get
    suggestions.
    Till now my testing server was a VMWare-Image from http://es.cohesiveft.com
    http://es.cohesiveft.com (Ubuntu 8.10, Tomcat6, Java5).
    Now I'm using a Debian Etch Server with Tomcat5.5 and Java6.

    Code-Sample:
    String indexName = indexLocation;
    String queryString = null;
    queryString = URLDecoder.decode(request.getParameter("q"), "UTF-8");
    SpellChecker spellchecker = new
    SpellChecker(FSDirectory.getDirectory(indexName));
    String[] suggestions = spellchecker.suggestSimilar(queryString, 5,
    IndexReader.open(indexName), "content", false);
    for(int i = 0; i < suggestions.length; i++) {
    out.println(suggestions[i]);
    }

    This worked fine on the old server, but on my new server this returns
    nothing.
    The index is generated by the nutch crawler, but this shouldn't be the
    problem.

    I've got the lucene-spellchecker-2.1.0.jar in the WEB-INF/lib/ (If I
    remove
    it, I get the expected errormessage.)

    So I don't know why I neither get results, nor an errormessage.
    --
    View this message in context: http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p20910159.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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

    Lucene Helpful Hints:
    http://wiki.apache.org/lucene-java/BasicsOfPerformance
    http://wiki.apache.org/lucene-java/LuceneFAQ











    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Matthias W. at Dec 12, 2008 at 9:35 am
    Yes, I'm passing the same index for Spellchecker and IndexReader.
    I'm going to test if this is a reason for my problem.

    But I still don't understand why the same code is working on the testserver.

    I think this could be because of the rights from tomcat.
    Is there any tutorial about the tomcat configuration for lucene with debian?
    Or can anyone tell me what's really important? I also don't know why there
    are two webapps folders (/var/lib/tomcat5.5/webapps and
    /usr/share/tomcat5.5-webapps). I made my JSP's into
    /var/lib/tomcat5.5/webapps.
    I copied the files from my testserver including the WEB-INF, could this be
    the reason?

    The changes:
    Ubuntu 8.10 -> Debian Etch
    Java5 -> Java6
    Tomcat6 -> Tomcat 5.5



    Grant Ingersoll-6 wrote:
    So, what changed with the server?

    From the looks of your code, you're passing the same index into both
    the Spellchecker and the IndexReader. The spelling index is separate
    from the main index.

    See the example at:
    http://lucene.apache.org/java/2_4_0/api/contrib-spellchecker/org/apache/lucene/search/spell/SpellChecker.html

    See also my Boot Camp examples at:
    http://www.lucenebootcamp.com/LuceneBootCamp/training/src/test/java/com/lucenebootcamp/training/basic/ContribExamplesTest.java
    Have a look at the testSpelling code there

    HTH,
    Grant

    On Dec 9, 2008, at 2:50 AM, Matthias W. wrote:


    Hi,
    I'm using Lucene's SpellChecker (Lucene 2.1.0) class to get
    suggestions.
    Till now my testing server was a VMWare-Image from
    http://es.cohesiveft.com
    http://es.cohesiveft.com (Ubuntu 8.10, Tomcat6, Java5).
    Now I'm using a Debian Etch Server with Tomcat5.5 and Java6.

    Code-Sample:
    String indexName = indexLocation;
    String queryString = null;
    queryString = URLDecoder.decode(request.getParameter("q"), "UTF-8");
    SpellChecker spellchecker = new
    SpellChecker(FSDirectory.getDirectory(indexName));
    String[] suggestions = spellchecker.suggestSimilar(queryString, 5,
    IndexReader.open(indexName), "content", false);
    for(int i = 0; i < suggestions.length; i++) {
    out.println(suggestions[i]);
    }

    This worked fine on the old server, but on my new server this returns
    nothing.
    The index is generated by the nutch crawler, but this shouldn't be the
    problem.

    I've got the lucene-spellchecker-2.1.0.jar in the WEB-INF/lib/ (If I
    remove
    it, I get the expected errormessage.)

    So I don't know why I neither get results, nor an errormessage.
    --
    View this message in context:
    http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p20910159.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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

    Lucene Helpful Hints:
    http://wiki.apache.org/lucene-java/BasicsOfPerformance
    http://wiki.apache.org/lucene-java/LuceneFAQ











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

    --
    View this message in context: http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p20971594.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Matthias W. at Dec 15, 2008 at 2:54 pm
    I fixed this problem by writing an external Java class and changing completly
    to Lucene-2.4.0.

    The SpellChecker now returns results but it is very slow.

    My index contains about 20000 words, I don't think this is too much.

    How can I speed it up?

    My temporary method:
    public static Vector suggest(String query, String indexName, String field,
    float accuracy) {
    Vector v = new Vector();
    String[] suggestions = null;

    try {
    SpellChecker spellchecker = new SpellChecker(new RAMDirectory()/*, new
    JaroWinklerDistance()*/);
    spellchecker.indexDictionary(new
    LuceneDictionary(IndexReader.open(indexName), field));
    spellchecker.setAccuracy(accuracy);
    suggestions = spellchecker.suggestSimilar(query, 5);
    } catch (Exception e) {}

    for(int i = 0; i < suggestions.length; i++) {
    v.add(suggestions[i]);
    }

    return v;
    }



    Matthias W. wrote:
    Hi,
    I'm using Lucene's SpellChecker (Lucene 2.1.0) class to get suggestions.
    Till now my testing server was a VMWare-Image from
    http://es.cohesiveft.com http://es.cohesiveft.com (Ubuntu 8.10, Tomcat6,
    Java5).
    Now I'm using a Debian Etch Server with Tomcat5.5 and Java6.

    Code-Sample:
    String indexName = indexLocation;
    String queryString = null;
    queryString = URLDecoder.decode(request.getParameter("q"), "UTF-8");
    SpellChecker spellchecker = new
    SpellChecker(FSDirectory.getDirectory(indexName));
    String[] suggestions = spellchecker.suggestSimilar(queryString, 5,
    IndexReader.open(indexName), "content", false);
    for(int i = 0; i < suggestions.length; i++) {
    out.println(suggestions[i]);
    }

    This worked fine on the old server, but on my new server this returns
    nothing.
    The index is generated by the nutch crawler, but this shouldn't be the
    problem.

    I've got the lucene-spellchecker-2.1.0.jar in the WEB-INF/lib/ (If I
    remove it, I get the expected errormessage.)

    So I don't know why I neither get results, nor an errormessage.
    --
    View this message in context: http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p21015278.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Chris Hostetter at Dec 20, 2008 at 6:24 pm
    : How can I speed it up?

    don't construct a new LuceneDictionary/IndexReader on every "suggest" call
    ... construct them once, and reuse them for each suggestion.

    : My temporary method:
    : public static Vector suggest(String query, String indexName, String field,
    : float accuracy) {
    : Vector v = new Vector();
    : String[] suggestions = null;
    :
    : try {
    : SpellChecker spellchecker = new SpellChecker(new RAMDirectory()/*, new
    : JaroWinklerDistance()*/);
    : spellchecker.indexDictionary(new
    : LuceneDictionary(IndexReader.open(indexName), field));
    : spellchecker.setAccuracy(accuracy);
    : suggestions = spellchecker.suggestSimilar(query, 5);
    : } catch (Exception e) {}
    :
    : for(int i = 0; i < suggestions.length; i++) {
    : v.add(suggestions[i]);
    : }
    :
    : return v;
    : }


    -Hoss


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Matthias W. at Dec 22, 2008 at 11:00 am
    Thanks for your answer.
    I already found the reason for the bad performance.

    hossman wrote:
    don't construct a new LuceneDictionary/IndexReader on every "suggest" call
    ... construct them once, and reuse them for each suggestion.
    This was the first thing I did, but the effect was not that big...

    The reason was the usage of the RAMDirectory. Now I'm usig
    FSDirectory.getDirectory("/dictionary") instead of new RAMDirectory() and it
    works fine.
    --
    View this message in context: http://www.nabble.com/Lucene-SpellChecker-returns-no-suggetions-after-changing-Server-tp20910159p21125964.html
    Sent from the Lucene - Java Users mailing list archive at Nabble.com.


    ---------------------------------------------------------------------
    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
postedDec 9, '08 at 7:50a
activeDec 22, '08 at 11:00a
posts7
users3
websitelucene.apache.org

People

Translate

site design / logo © 2022 Grokbase