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.schema;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.apache.solr.core.SolrCore;
22: import org.apache.solr.request.LocalSolrQueryRequest;
23: import org.apache.solr.request.MapSolrParams;
24: import org.apache.solr.request.SolrParams;
25: import org.apache.solr.request.SolrQueryRequest;
26: import org.apache.solr.util.AbstractSolrTestCase;
27:
28: public class IndexSchemaTest extends AbstractSolrTestCase {
29:
30: @Override
31: public String getSchemaFile() {
32: return "schema.xml";
33: }
34:
35: @Override
36: public String getSolrConfigFile() {
37: return "solrconfig.xml";
38: }
39:
40: @Override
41: public void setUp() throws Exception {
42: super .setUp();
43: }
44:
45: @Override
46: public void tearDown() throws Exception {
47: super .tearDown();
48: }
49:
50: /**
51: * This test assumes the schema includes:
52: * <dynamicField name="dynamic_*" type="string" indexed="true" stored="true"/>
53: * <dynamicField name="*_dynamic" type="string" indexed="true" stored="true"/>
54: */
55: public void testDynamicCopy() {
56: assertU(adoc("id", "10", "title", "test", "aaa_dynamic", "aaa"));
57: assertU(commit());
58:
59: Map<String, String> args = new HashMap<String, String>();
60: args.put(SolrParams.Q, "title:test");
61: args.put("indent", "true");
62: SolrQueryRequest req = new LocalSolrQueryRequest(SolrCore
63: .getSolrCore(), new MapSolrParams(args));
64:
65: assertQ("Make sure they got in", req, "//*[@numFound='1']",
66: "//result/doc[1]/int[@name='id'][.='10']");
67:
68: args = new HashMap<String, String>();
69: args.put(SolrParams.Q, "aaa_dynamic:aaa");
70: args.put("indent", "true");
71: req = new LocalSolrQueryRequest(SolrCore.getSolrCore(),
72: new MapSolrParams(args));
73: assertQ("dynamic source", req, "//*[@numFound='1']",
74: "//result/doc[1]/int[@name='id'][.='10']");
75:
76: args = new HashMap<String, String>();
77: args.put(SolrParams.Q, "dynamic_aaa:aaa");
78: args.put("indent", "true");
79: req = new LocalSolrQueryRequest(SolrCore.getSolrCore(),
80: new MapSolrParams(args));
81: assertQ("dynamic destination", req, "//*[@numFound='1']",
82: "//result/doc[1]/int[@name='id'][.='10']");
83: }
84: }
|