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

« back to all changes in this revision

Viewing changes to solr/core/src/test/org/apache/solr/search/TestSolrQueryParser.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
 
/**
2
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 
 * contributor license agreements.  See the NOTICE file distributed with
4
 
 * this work for additional information regarding copyright ownership.
5
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 
 * (the "License"); you may not use this file except in compliance with
7
 
 * the License.  You may obtain a copy of the License at
8
 
 *
9
 
 *     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
 
 */
17
 
package org.apache.solr.search;
18
 
 
19
 
import org.apache.solr.SolrTestCaseJ4;
20
 
import org.junit.BeforeClass;
21
 
import org.junit.Test;
22
 
 
23
 
 
24
 
public class TestSolrQueryParser extends SolrTestCaseJ4 {
25
 
  @BeforeClass
26
 
  public static void beforeClass() throws Exception {
27
 
    initCore("solrconfig.xml", "schema12.xml");
28
 
    createIndex();
29
 
  }
30
 
 
31
 
  public static void createIndex() {
32
 
    String v;
33
 
    v="how now brown cow";
34
 
    assertU(adoc("id","1", "text",v,  "text_np",v));
35
 
    v="now cow";
36
 
    assertU(adoc("id","2", "text",v,  "text_np",v));
37
 
    assertU(commit());
38
 
  }
39
 
 
40
 
  @Test
41
 
  public void testPhrase() {
42
 
    // should generate a phrase of "now cow" and match only one doc
43
 
    assertQ(req("q","text:now-cow", "indent","true")
44
 
        ,"//*[@numFound='1']"
45
 
    );
46
 
    // should generate a query of (now OR cow) and match both docs
47
 
    assertQ(req("q","text_np:now-cow", "indent","true")
48
 
        ,"//*[@numFound='2']"
49
 
    );
50
 
  }
51
 
 
52
 
}