Added: 
lucene/solr/trunk/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java?rev=669485&view=auto
==============================================================================
--- 
lucene/solr/trunk/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
 (added)
+++ 
lucene/solr/trunk/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
 Thu Jun 19 06:46:54 2008
@@ -0,0 +1,298 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.spelling;
+/**
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.spell.JaroWinklerDistance;
+import org.apache.lucene.search.spell.SpellChecker;
+import org.apache.lucene.search.spell.StringDistance;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.util.AbstractSolrTestCase;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @since solr 1.3
+ */
+public class IndexBasedSpellCheckerTest extends AbstractSolrTestCase {
+  protected SpellingQueryConverter queryConverter;
+
+  protected static String[] DOCS = new String[]{
+          "This is a title",
+          "The quick reb fox jumped over the lazy brown dogs.",
+          "This is a document",
+          "another document",
+          "red fox",
+          "green bun",
+          "green bud"
+  };
+
+
+  public String getSchemaFile() {
+    return "schema.xml";
+  }
+
+  public String getSolrConfigFile() {
+    return "solrconfig.xml";
+  }
+
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    //Index something with a title
+    for (int i = 0; i < DOCS.length; i++) {
+      assertU(adoc("id", String.valueOf(i), "title", DOCS[i]));
+    }
+    assertU("commit",
+            commit());
+    String allq = "id:[0 TO 3]";
+    assertQ("docs not added", req(allq));
+    queryConverter = new SimpleQueryConverter();
+  }
+
+  public void testSpelling() throws Exception {
+    IndexBasedSpellChecker checker = new IndexBasedSpellChecker();
+
+    NamedList spellchecker = new NamedList();
+    spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
+
+    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+    File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
+    indexDir.mkdirs();
+    spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, 
indexDir.getAbsolutePath());
+    spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
+    spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, 
spellchecker);
+    SolrCore core = h.getCore();
+
+    String dictName = checker.init(spellchecker, core.getResourceLoader());
+    assertTrue(dictName + " is not equal to " + 
SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+            dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+    checker.build(core);
+
+    IndexReader reader = core.getSearcher().get().getReader();
+    Collection<Token> tokens = queryConverter.convert("documemt");
+    SpellingResult result = checker.getSuggestions(tokens, reader);
+    assertTrue("result is null and it shouldn't be", result != null);
+    //should be lowercased, b/c we are using a lowercasing analyzer
+    Map<String, Integer> suggestions = result.get(tokens.iterator().next());
+    assertTrue("documemt is null and it shouldn't be", suggestions != null);
+    assertTrue("documemt Size: " + suggestions.size() + " is not: " + 1, 
suggestions.size() == 1);
+    Map.Entry<String, Integer> entry = 
suggestions.entrySet().iterator().next();
+    assertTrue(entry.getKey() + " is not equal to " + "document", 
entry.getKey().equals("document") == true);
+    assertTrue(entry.getValue() + " does not equal: " + 
SpellingResult.NO_FREQUENCY_INFO, entry.getValue() == 
SpellingResult.NO_FREQUENCY_INFO);
+
+    //test something not in the spell checker
+    tokens = queryConverter.convert("super");
+    result = checker.getSuggestions(tokens, reader);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is not null and it should be", suggestions == 
null);
+
+    //test something that is spelled correctly
+    tokens = queryConverter.convert("document");
+    result = checker.getSuggestions(tokens, reader);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is null and it shouldn't be", suggestions == null);
+
+    //Has multiple possibilities, but the exact exists, so that should be 
returned
+    tokens = queryConverter.convert("red");
+    result = checker.getSuggestions(tokens, reader, 2);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is not null and it should be", suggestions == 
null);
+
+    //Try out something which should have multiple suggestions
+    tokens = queryConverter.convert("bug");
+    result = checker.getSuggestions(tokens, reader, 2);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is null and it shouldn't be", suggestions != null);
+    assertTrue("suggestions Size: " + suggestions.size() + " is not: " + 2, 
suggestions.size() == 2);
+
+    entry = suggestions.entrySet().iterator().next();
+    assertTrue(entry.getKey() + " is equal to " + "bug and it shouldn't be", 
entry.getKey().equals("bug") == false);
+    assertTrue(entry.getValue() + " does not equal: " + 
SpellingResult.NO_FREQUENCY_INFO, entry.getValue() == 
SpellingResult.NO_FREQUENCY_INFO);
+
+    entry = suggestions.entrySet().iterator().next();
+    assertTrue(entry.getKey() + " is equal to " + "bug and it shouldn't be", 
entry.getKey().equals("bug") == false);
+    assertTrue(entry.getValue() + " does not equal: " + 
SpellingResult.NO_FREQUENCY_INFO, entry.getValue() == 
SpellingResult.NO_FREQUENCY_INFO);
+  }
+
+  public void testExtendedResults() throws Exception {
+    IndexBasedSpellChecker checker = new IndexBasedSpellChecker();
+    NamedList spellchecker = new NamedList();
+    spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
+
+    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+    File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
+    indexDir.mkdirs();
+    spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, 
indexDir.getAbsolutePath());
+    spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
+    spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, 
spellchecker);
+    SolrCore core = h.getCore();
+    String dictName = checker.init(spellchecker, core.getResourceLoader());
+    assertTrue(dictName + " is not equal to " + 
SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+            dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+    checker.build(core);
+
+    IndexReader reader = core.getSearcher().get().getReader();
+    Collection<Token> tokens = queryConverter.convert("documemt");
+    SpellingResult result = checker.getSuggestions(tokens, reader, 1, false, 
true);
+    assertTrue("result is null and it shouldn't be", result != null);
+    //should be lowercased, b/c we are using a lowercasing analyzer
+    Map<String, Integer> suggestions = result.get(tokens.iterator().next());
+    assertTrue("documemt is null and it shouldn't be", suggestions != null);
+    assertTrue("documemt Size: " + suggestions.size() + " is not: " + 1, 
suggestions.size() == 1);
+    Map.Entry<String, Integer> entry = 
suggestions.entrySet().iterator().next();
+    assertTrue(entry.getKey() + " is not equal to " + "document", 
entry.getKey().equals("document") == true);
+    assertTrue(entry.getValue() + " does not equal: " + 2, entry.getValue() == 
2);
+
+    //test something not in the spell checker
+    tokens = queryConverter.convert("super");
+    result = checker.getSuggestions(tokens, reader, 1, false, true);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is not null and it should be", suggestions == 
null);
+
+    tokens = queryConverter.convert("document");
+    result = checker.getSuggestions(tokens, reader, 1, false, true);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is not null and it should be", suggestions == 
null);
+  }
+
+  private class TestSpellChecker extends IndexBasedSpellChecker{
+    public SpellChecker getSpellChecker(){
+      return spellChecker;
+    }
+  }
+
+  public void testAlternateDistance() throws Exception {
+    TestSpellChecker checker = new TestSpellChecker();
+    NamedList spellchecker = new NamedList();
+    spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
+
+    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+    File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
+    indexDir.mkdirs();
+    spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, 
indexDir.getAbsolutePath());
+    spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
+    spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, 
spellchecker);
+    spellchecker.add(AbstractLuceneSpellChecker.STRING_DISTANCE, 
JaroWinklerDistance.class.getName());
+    SolrCore core = h.getCore();
+    String dictName = checker.init(spellchecker, core.getResourceLoader());
+    assertTrue(dictName + " is not equal to " + 
SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+            dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+    checker.build(core);
+    SpellChecker sc = checker.getSpellChecker();
+    assertTrue("sc is null and it shouldn't be", sc != null);
+    StringDistance sd = sc.getStringDistance();
+    assertTrue("sd is null and it shouldn't be", sd != null);
+    assertTrue("sd is not an instance of " + 
JaroWinklerDistance.class.getName(), sd instanceof JaroWinklerDistance);
+  }
+
+  public void testAlternateLocation() throws Exception {
+    String[] ALT_DOCS = new String[]{
+            "jumpin jack flash",
+            "Sargent Peppers Lonely Hearts Club Band",
+            "Born to Run",
+            "Thunder Road",
+            "Londons Burning",
+            "A Horse with No Name",
+            "Sweet Caroline"
+    };
+
+    IndexBasedSpellChecker checker = new IndexBasedSpellChecker();
+    NamedList spellchecker = new NamedList();
+    spellchecker.add("classname", IndexBasedSpellChecker.class.getName());
+
+    File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+    File indexDir = new File(tmpDir, "spellingIdx" + new Date().getTime());
+    //create a standalone index
+    File altIndexDir = new File(tmpDir, "alternateIdx" + new Date().getTime());
+    IndexWriter iw = new IndexWriter(altIndexDir, new WhitespaceAnalyzer(), 
IndexWriter.MaxFieldLength.LIMITED);
+    for (int i = 0; i < ALT_DOCS.length; i++) {
+      Document doc = new Document();
+      doc.add(new Field("title", ALT_DOCS[i], Field.Store.YES, 
Field.Index.TOKENIZED));
+      iw.addDocument(doc);
+    }
+    iw.optimize();
+    iw.close();
+    indexDir.mkdirs();
+    spellchecker.add(AbstractLuceneSpellChecker.INDEX_DIR, 
indexDir.getAbsolutePath());
+    spellchecker.add(AbstractLuceneSpellChecker.LOCATION, 
altIndexDir.getAbsolutePath());
+    spellchecker.add(IndexBasedSpellChecker.FIELD, "title");
+    spellchecker.add(AbstractLuceneSpellChecker.SPELLCHECKER_ARG_NAME, 
spellchecker);
+    SolrCore core = h.getCore();
+    String dictName = checker.init(spellchecker, core.getResourceLoader());
+    assertTrue(dictName + " is not equal to " + 
SolrSpellChecker.DEFAULT_DICTIONARY_NAME,
+            dictName.equals(SolrSpellChecker.DEFAULT_DICTIONARY_NAME) == true);
+    checker.build(core);
+
+    IndexReader reader = core.getSearcher().get().getReader();
+    Collection<Token> tokens = queryConverter.convert("flesh");
+    SpellingResult result = checker.getSuggestions(tokens, reader, 1, false, 
true);
+    assertTrue("result is null and it shouldn't be", result != null);
+    //should be lowercased, b/c we are using a lowercasing analyzer
+    Map<String, Integer> suggestions = result.get(tokens.iterator().next());
+    assertTrue("flesh is null and it shouldn't be", suggestions != null);
+    assertTrue("flesh Size: " + suggestions.size() + " is not: " + 1, 
suggestions.size() == 1);
+    Map.Entry<String, Integer> entry = 
suggestions.entrySet().iterator().next();
+    assertTrue(entry.getKey() + " is not equal to " + "flash", 
entry.getKey().equals("flash") == true);
+    assertTrue(entry.getValue() + " does not equal: " + 1, entry.getValue() == 
1);
+
+    //test something not in the spell checker
+    tokens = queryConverter.convert("super");
+    result = checker.getSuggestions(tokens, reader, 1, false, true);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is not null and it should be", suggestions == 
null);
+
+    tokens = queryConverter.convert("Caroline");
+    result = checker.getSuggestions(tokens, reader, 1, false, true);
+    assertTrue("result is null and it shouldn't be", result != null);
+    suggestions = result.get(tokens.iterator().next());
+    assertTrue("suggestions is not null and it should be", suggestions == 
null);
+
+  }
+}
+

Propchange: 
lucene/solr/trunk/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SimpleQueryConverter.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/spelling/SimpleQueryConverter.java?rev=669485&view=auto
==============================================================================
--- 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SimpleQueryConverter.java 
(added)
+++ 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SimpleQueryConverter.java 
Thu Jun 19 06:46:54 2008
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.spelling;
+
+import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.lucene.analysis.TokenStream;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.io.StringReader;
+import java.io.IOException;
+
+
+/**
+ *
+ * @since solr 1.3
+ **/
+class SimpleQueryConverter extends SpellingQueryConverter{
+  @Override
+  public Collection<Token> convert(String origQuery) {
+    Collection<Token> result = new HashSet<Token>();
+    WhitespaceAnalyzer analyzer = new WhitespaceAnalyzer();
+    TokenStream ts = analyzer.tokenStream("", new StringReader(origQuery));
+    Token tok = null;
+    try {
+      while ((tok = ts.next()) != null){
+        result.add(tok);
+      }
+    } catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+    return result;
+  }
+}

Propchange: 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SimpleQueryConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java?rev=669485&view=auto
==============================================================================
--- 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
 (added)
+++ 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
 Thu Jun 19 06:46:54 2008
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.spelling;
+
+import java.util.Collection;
+
+import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.util.AbstractSolrTestCase;
+
+
+/**
+ *
+ * @since solr 1.3
+ **/
+public class SpellingQueryConverterTest extends AbstractSolrTestCase {
+
+  public String getSchemaFile() {
+    return "schema.xml";
+  }
+
+  public String getSolrConfigFile() {
+    return "solrconfig.xml";
+  }
+
+
+  public void test() throws Exception {
+    SpellingQueryConverter converter = new SpellingQueryConverter();
+    converter.init(new NamedList());
+    converter.setAnalyzer(new WhitespaceAnalyzer());
+    Collection<Token> tokens = converter.convert("field:foo");
+    assertTrue("tokens is null and it shouldn't be", tokens != null);
+    assertTrue("tokens Size: " + tokens.size() + " is not: " + 1, 
tokens.size() == 1);
+  }
+
+
+}

Propchange: 
lucene/solr/trunk/src/test/org/apache/solr/spelling/SpellingQueryConverterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml?rev=669485&r1=669484&r2=669485&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml (original)
+++ lucene/solr/trunk/src/test/test-files/solr/conf/solrconfig.xml Thu Jun 19 
06:46:54 2008
@@ -136,7 +136,7 @@
     -->
     <maxBooleanClauses>1024</maxBooleanClauses>
 
-    
+
     <!-- Cache specification for Filters or DocSets - unordered set of *all* 
documents
          that match a particular query.
       -->
@@ -281,7 +281,7 @@
 
   <requestHandler name="test" class="solr.tst.TestRequestHandler" />
 
-  <!-- test query parameter defaults --> 
+  <!-- test query parameter defaults -->
   <requestHandler name="defaults" class="solr.StandardRequestHandler">
     <lst name="defaults">
       <int name="rows">4</int>
@@ -289,8 +289,8 @@
       <str name="hl.fl">text,name,subject,title,whitetok</str>
     </lst>
   </requestHandler>
-  
-  <!-- test query parameter defaults --> 
+
+  <!-- test query parameter defaults -->
   <requestHandler name="lazy" class="solr.StandardRequestHandler" 
startup="lazy">
     <lst name="defaults">
       <int name="rows">4</int>
@@ -307,7 +307,7 @@
     <str name="queryFieldType">string</str>
     <str name="config-file">elevate.xml</str>
   </searchComponent>
- 
+
   <requestHandler name="/elevate" 
class="org.apache.solr.handler.component.SearchHandler">
     <lst name="defaults">
       <str name="echoParams">explicit</str>
@@ -316,7 +316,51 @@
       <str>elevate</str>
     </arr>
   </requestHandler>
-  
+
+  <searchComponent name="spellcheck" 
class="org.apache.solr.handler.component.SpellCheckComponent">
+    <lst name="defaults">
+      <!-- omp = Only More Popular -->
+      <str name="spellcheck.onlyMorePopular">false</str>
+      <!-- exr = Extended Results -->
+      <str name="spellcheck.extendedResults">false</str>
+      <!--  The number of suggestions to return -->
+      <str name="spellcheck.count">1</str>
+    </lst>
+    <str name="queryAnalyzerFieldType">lowerfilt</str>
+
+    <lst name="spellchecker">
+      <str name="name">default</str>
+      <str name="field">lowerfilt</str>
+      <str name="spellcheckIndexDir">./spellchecker</str>
+
+    </lst>
+    <lst name="spellchecker">
+      <str name="name">jarowinkler</str>
+      <str name="field">lowerfilt</str>
+      <!-- Use a different Distance Measure -->
+      <str 
name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
+      <str name="spellcheckIndexDir">./spellchecker</str>
+
+    </lst>
+    <lst name="spellchecker">
+      <str name="classname">solr.FileBasedSpellChecker</str>
+      <str name="name">external</str>
+      <str name="sourceLocation">spellings.txt</str>
+      <str name="characterEncoding">UTF-8</str>
+      <str name="spellcheckIndexDir">./spellchecker</str>
+    </lst>
+  </searchComponent>
+  <!--
+  The SpellingQueryConverter to convert raw (CommonParams.Q) queries into 
tokens.  Uses a simple regular expression
+   to strip off field markup, boosts, ranges, etc. but it is not guaranteed to 
match an exact parse from the query parser.
+   -->
+  <queryConverter name="queryConverter" 
class="org.apache.solr.spelling.SpellingQueryConverter"/>
+
+  <requestHandler name="spellCheckCompRH" 
class="org.apache.solr.handler.component.SearchHandler">
+    <arr name="last-components">
+      <str>spellcheck</str>
+    </arr>
+  </requestHandler>
 
   <highlighting>
    <!-- Configure the standard fragmenter -->
@@ -325,13 +369,13 @@
      <int name="hl.fragsize">100</int>
     </lst>
    </fragmenter>
-   
+
    <fragmenter name="regex" class="org.apache.solr.highlight.RegexFragmenter">
     <lst name="defaults">
      <int name="hl.fragsize">70</int>
     </lst>
    </fragmenter>
-   
+
    <!-- Configure the standard formatter -->
    <formatter name="html" class="org.apache.solr.highlight.HtmlFormatter" 
default="true">
     <lst name="defaults">

Added: lucene/solr/trunk/src/test/test-files/spellings.txt
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/test-files/spellings.txt?rev=669485&view=auto
==============================================================================
--- lucene/solr/trunk/src/test/test-files/spellings.txt (added)
+++ lucene/solr/trunk/src/test/test-files/spellings.txt Thu Jun 19 06:46:54 2008
@@ -0,0 +1,16 @@
+foo
+bar
+Solr
+junk
+foo
+bar
+Solr
+junk
+foo
+bar
+Solr
+junk
+foo
+bar
+Solr
+junk
\ No newline at end of file

Propchange: lucene/solr/trunk/src/test/test-files/spellings.txt
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to