1
package org.apache.solr.handler.component;
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
11
* http://www.apache.org/licenses/LICENSE-2.0
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.
20
import org.apache.solr.BaseDistributedSearchTestCase;
21
import org.apache.solr.client.solrj.SolrServer;
22
import org.apache.solr.common.params.ModifiableSolrParams;
25
* Test for SpellCheckComponent's distributed querying
28
* @version $Id: DistributedSpellCheckComponentTest.java 1065290 2011-01-30 14:25:12Z rmuir $
29
* @see org.apache.solr.handler.component.SpellCheckComponent
31
public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTestCase {
33
public DistributedSpellCheckComponentTest()
39
private String saveProp;
41
public void setUp() throws Exception {
42
// this test requires FSDir
43
saveProp = System.getProperty("solr.directoryFactory");
44
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
49
public void tearDown() throws Exception {
52
System.clearProperty("solr.directoryFactory");
54
System.setProperty("solr.directoryFactory", saveProp);
57
private void q(Object... q) throws Exception {
58
final ModifiableSolrParams params = new ModifiableSolrParams();
60
for (int i = 0; i < q.length; i += 2) {
61
params.add(q[i].toString(), q[i + 1].toString());
64
controlClient.query(params);
66
// query a random server
67
params.set("shards", shards);
68
int which = r.nextInt(clients.size());
69
SolrServer client = clients.get(which);
74
public void doTest() throws Exception {
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.");
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");
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");
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");