01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.analysis;
17:
18: import org.apache.solr.util.AbstractSolrTestCase;
19: import org.apache.solr.util.TestHarness;
20: import org.apache.solr.request.SolrQueryRequest;
21:
22: /**
23: * New WordDelimiterFilter tests... most of the tests are in ConvertedLegacyTest
24: */
25: public class TestWordDelimiterFilter extends AbstractSolrTestCase {
26: public String getSchemaFile() {
27: return "solr/conf/schema.xml";
28: }
29:
30: public String getSolrConfigFile() {
31: return "solr/conf/solrconfig.xml";
32: }
33:
34: public void posTst(String v1, String v2, String s1, String s2) {
35: assertU(adoc("id", "42", "subword", v1, "subword", v2));
36: assertU(commit());
37:
38: // there is a positionIncrementGap of 100 between field values, so
39: // we test if that was maintained.
40: assertQ("position increment lost", req("+id:42 +subword:\""
41: + s1 + ' ' + s2 + "\"~90"), "//result[@numFound=0]");
42: assertQ("position increment lost", req("+id:42 +subword:\""
43: + s1 + ' ' + s2 + "\"~110"), "//result[@numFound=1]");
44: }
45:
46: public void testRetainPositionIncrement() {
47: posTst("foo", "bar", "foo", "bar");
48: posTst("-foo-", "-bar-", "foo", "bar");
49: posTst("foo", "bar", "-foo-", "-bar-");
50:
51: posTst("123", "456", "123", "456");
52: posTst("/123/", "/456/", "123", "456");
53:
54: posTst("/123/abc", "qwe/456/", "abc", "qwe");
55:
56: posTst("zoo-foo", "bar-baz", "foo", "bar");
57: posTst("zoo-foo-123", "456-bar-baz", "foo", "bar");
58: }
59:
60: public void testNoGenerationEdgeCase() {
61: assertU(adoc("id", "222", "numberpartfail", "123.123.123.123"));
62: }
63:
64: }
|