~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.solr.handler.component;
2
 
 
3
 
/**
4
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
5
 
 * contributor license agreements.  See the NOTICE file distributed with
6
 
 * this work for additional information regarding copyright ownership.
7
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
8
 
 * (the "License"); you may not use this file except in compliance with
9
 
 * the License.  You may obtain a copy of the License at
10
 
 *
11
 
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 
 *
13
 
 * Unless required by applicable law or agreed to in writing, software
14
 
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
 * See the License for the specific language governing permissions and
17
 
 * limitations under the License.
18
 
 */
19
 
 
20
 
import org.apache.solr.BaseDistributedSearchTestCase;
21
 
import org.apache.solr.client.solrj.SolrServer;
22
 
import org.apache.solr.common.params.ModifiableSolrParams;
23
 
 
24
 
/**
25
 
 * Test for SpellCheckComponent's distributed querying
26
 
 *
27
 
 * @since solr 1.5
28
 
 * @version $Id: DistributedSpellCheckComponentTest.java 1065290 2011-01-30 14:25:12Z rmuir $
29
 
 * @see org.apache.solr.handler.component.SpellCheckComponent
30
 
 */
31
 
public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTestCase {
32
 
  
33
 
        public DistributedSpellCheckComponentTest()
34
 
        {
35
 
                //fixShardCount=true;
36
 
                //shardCount=2;
37
 
        }
38
 
        
39
 
  private String saveProp;
40
 
  @Override
41
 
  public void setUp() throws Exception {
42
 
    // this test requires FSDir
43
 
    saveProp = System.getProperty("solr.directoryFactory");
44
 
    System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
45
 
    super.setUp();
46
 
  }
47
 
  
48
 
  @Override
49
 
  public void tearDown() throws Exception {
50
 
    super.tearDown();
51
 
    if (saveProp == null)
52
 
      System.clearProperty("solr.directoryFactory");
53
 
    else
54
 
      System.setProperty("solr.directoryFactory", saveProp);
55
 
  }
56
 
  
57
 
  private void q(Object... q) throws Exception {
58
 
    final ModifiableSolrParams params = new ModifiableSolrParams();
59
 
 
60
 
    for (int i = 0; i < q.length; i += 2) {
61
 
      params.add(q[i].toString(), q[i + 1].toString());
62
 
    }
63
 
 
64
 
    controlClient.query(params);
65
 
 
66
 
    // query a random server
67
 
    params.set("shards", shards);
68
 
    int which = r.nextInt(clients.size());
69
 
    SolrServer client = clients.get(which);
70
 
    client.query(params);
71
 
  }
72
 
  
73
 
  @Override
74
 
  public void doTest() throws Exception {
75
 
        del("*:*");
76
 
    index(id, "1", "lowerfilt", "toyota");
77
 
    index(id, "2", "lowerfilt", "chevrolet");
78
 
    index(id, "3", "lowerfilt", "suzuki");
79
 
    index(id, "4", "lowerfilt", "ford");
80
 
    index(id, "5", "lowerfilt", "ferrari");
81
 
    index(id, "6", "lowerfilt", "jaguar");
82
 
    index(id, "7", "lowerfilt", "mclaren");
83
 
    index(id, "8", "lowerfilt", "sonata");
84
 
    index(id, "9", "lowerfilt", "The quick red fox jumped over the lazy brown dogs.");
85
 
    index(id, "10", "lowerfilt", "blue");
86
 
    index(id, "12", "lowerfilt", "glue");
87
 
    index(id, "13", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
88
 
    index(id, "14", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
89
 
    index(id, "15", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
90
 
    index(id, "16", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
91
 
    index(id, "17", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
92
 
    index(id, "18", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
93
 
    index(id, "19", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
94
 
    index(id, "20", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
95
 
    index(id, "21", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
96
 
    index(id, "22", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
97
 
    index(id, "23", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
98
 
    index(id, "24", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
99
 
    commit();
100
 
 
101
 
    handle.clear();
102
 
    handle.put("QTime", SKIPVAL);
103
 
    handle.put("timestamp", SKIPVAL);
104
 
    handle.put("maxScore", SKIPVAL);
105
 
    // we care only about the spellcheck results
106
 
    handle.put("response", SKIP);
107
 
    q("q", "*:*", SpellCheckComponent.SPELLCHECK_BUILD, "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH");
108
 
    
109
 
    query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH");
110
 
    query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","toyata", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true");
111
 
    query("q", "*:*", "fl", "id,lowerfilt", "spellcheck.q","bluo", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4");
112
 
    query("q", "The quick reb fox jumped over the lazy brown dogs", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "4", SpellCheckComponent.SPELLCHECK_COLLATE, "true");
113
 
 
114
 
    query("q", "lowerfilt:(+quock +reb)", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "10", SpellCheckComponent.SPELLCHECK_COLLATE, "true", SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "10", SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true");
115
 
    query("q", "lowerfilt:(+quock +reb)", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "10", SpellCheckComponent.SPELLCHECK_COLLATE, "true", SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "10", SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "false");
116
 
    query("q", "lowerfilt:(+quock +reb)", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "10", SpellCheckComponent.SPELLCHECK_COLLATE, "true", SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "0", SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1", SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "false");
117
 
  }
118
 
}