001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.solr;
017:
018: import org.apache.solr.request.*;
019: import org.apache.solr.util.*;
020:
021: import java.util.*;
022: import java.io.IOException;
023:
024: /**
025: * This tests was converted from a legacy testing system.
026: *
027: * it does not represent the best practices that should be used when
028: * writing Solr JUnit tests
029: */
030: public class ConvertedLegacyTest extends AbstractSolrTestCase {
031:
032: public String getSchemaFile() {
033: return "schema.xml";
034: }
035:
036: public String getSolrConfigFile() {
037: return "solrconfig.xml";
038: }
039:
040: public void testABunchOfConvertedStuff() {
041: // these may be reused by things that need a special query
042: SolrQueryRequest req = null;
043: Map<String, String> args = new HashMap<String, String>();
044: lrf.args.put("version", "2.0");
045:
046: // compact the index, keep things from getting out of hand
047:
048: assertU("<optimize/>");
049:
050: // test query
051:
052: assertQ(req("qlkciyopsbgzyvkylsjhchghjrdf"),
053: "//result[@numFound='0']");
054:
055: // test escaping of ";"
056:
057: assertU("<delete><id>42</id></delete>");
058: assertU("<add><doc><field name=\"id\">42</field><field name=\"val_s\">aa;bb</field></doc></add>");
059: assertU("<commit/>");
060: assertQ(req("id:42 AND val_s:aa\\;bb"), "//*[@numFound='1']");
061: assertQ(req("id:42 AND val_s:\"aa;bb\""), "//*[@numFound='1']");
062: assertQ(req("id:42 AND val_s:\"aa\""), "//*[@numFound='0']");
063:
064: // test allowDups default of false
065:
066: assertU("<delete><id>42</id></delete>");
067: assertU("<add><doc><field name=\"id\">42</field><field name=\"val_s\">AAA</field></doc></add>");
068: assertU("<add><doc><field name=\"id\">42</field><field name=\"val_s\">BBB</field></doc></add>");
069: assertU("<commit/>");
070: assertQ(req("id:42"), "//*[@numFound='1'] ", "//str[.='BBB']");
071: assertU("<add><doc><field name=\"id\">42</field><field name=\"val_s\">CCC</field></doc></add>");
072: assertU("<add><doc><field name=\"id\">42</field><field name=\"val_s\">DDD</field></doc></add>");
073: assertU("<commit/>");
074: assertQ(req("id:42"), "//*[@numFound='1'] ", "//str[.='DDD']");
075: assertU("<delete><id>42</id></delete>");
076:
077: // test deletes
078:
079: assertU("<delete><query>id:[100 TO 110]</query></delete>");
080: assertU("<add allowDups=\"false\"><doc><field name=\"id\">101</field></doc></add>");
081: assertU("<add allowDups=\"false\"><doc><field name=\"id\">101</field></doc></add>");
082: assertU("<add allowDups=\"true\"><doc><field name=\"id\">105</field></doc></add>");
083: assertU("<add allowDups=\"false\"><doc><field name=\"id\">102</field></doc></add>");
084: assertU("<add allowDups=\"true\"><doc><field name=\"id\">103</field></doc></add>");
085: assertU("<add allowDups=\"false\"><doc><field name=\"id\">101</field></doc></add>");
086: assertU("<commit/>");
087: assertQ(req("id:[100 TO 110]"), "//*[@numFound='4']");
088: assertU("<delete><id>102</id></delete>");
089: assertU("<commit/>");
090: assertQ(req("id:[100 TO 110]"), "//*[@numFound='3']");
091: assertU("<delete><query>id:105</query></delete>");
092: assertU("<commit/>");
093: assertQ(req("id:[100 TO 110]"), "//*[@numFound='2']");
094: assertU("<delete><query>id:[100 TO 110]</query></delete>");
095: assertU("<commit/>");
096: assertQ(req("id:[100 TO 110]"), "//*[@numFound='0']");
097:
098: // test range
099:
100: assertU("<delete><id>44</id></delete>");
101: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">apple</field></doc></add>");
102: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">banana</field></doc></add>");
103: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">pear</field></doc></add>");
104: assertU("<commit/>");
105: assertQ(req("val_s:[a TO z]"), "//*[@numFound='3'] ",
106: "*[count(//doc)=3] ", "//*[@start='0']");
107: args = new HashMap<String, String>();
108: args.put("version", "2.0");
109: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
110: "standard", 2, 5, args);
111: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ",
112: "*//doc[1]/str[.='pear'] ", "//*[@start='2']");
113: args = new HashMap<String, String>();
114: args.put("version", "2.0");
115: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
116: "standard", 3, 5, args);
117: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
118: args = new HashMap<String, String>();
119: args.put("version", "2.0");
120: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
121: "standard", 4, 5, args);
122: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
123: args = new HashMap<String, String>();
124: args.put("version", "2.0");
125: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
126: "standard", 25, 5, args);
127: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
128: args = new HashMap<String, String>();
129: args.put("version", "2.0");
130: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
131: "standard", 0, 1, args);
132: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ",
133: "*//doc[1]/str[.='apple']");
134: args = new HashMap<String, String>();
135: args.put("version", "2.0");
136: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
137: "standard", 0, 2, args);
138: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=2] ",
139: "*//doc[2]/str[.='banana']");
140: args = new HashMap<String, String>();
141: args.put("version", "2.0");
142: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
143: "standard", 1, 1, args);
144: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=1] ",
145: "*//doc[1]/str[.='banana']");
146: args = new HashMap<String, String>();
147: args.put("version", "2.0");
148: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
149: "standard", 3, 1, args);
150: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
151: args = new HashMap<String, String>();
152: args.put("version", "2.0");
153: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
154: "standard", 4, 1, args);
155: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
156: args = new HashMap<String, String>();
157: args.put("version", "2.0");
158: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
159: "standard", 1, 0, args);
160: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
161: args = new HashMap<String, String>();
162: args.put("version", "2.0");
163: req = new LocalSolrQueryRequest(h.getCore(), "val_s:[a TO z]",
164: "standard", 0, 0, args);
165: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
166: args = new HashMap<String, String>();
167: args.put("version", "2.0");
168: req = new LocalSolrQueryRequest(h.getCore(),
169: "val_s:[a TO z];val_s asc", "standard", 0, 0, args);
170: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
171: args = new HashMap<String, String>();
172: args.put("version", "2.0");
173: req = new LocalSolrQueryRequest(h.getCore(),
174: "val_s:[a TO z];val_s desc", "standard", 0, 0, args);
175: assertQ(req, "//*[@numFound='3'] ", "*[count(//doc)=0]");
176: assertQ(req("val_s:[a TO b]"), "//*[@numFound='1']");
177: assertQ(req("val_s:[a TO cat]"), "//*[@numFound='2']");
178: assertQ(req("val_s:[a TO *]"), "//*[@numFound='3']");
179: assertQ(req("val_s:[* TO z]"), "//*[@numFound='3']");
180: assertQ(req("val_s:[* TO *]"), "//*[@numFound='3']");
181: assertQ(req("val_s:[apple TO pear]"), "//*[@numFound='3']");
182: assertQ(req("val_s:[bear TO boar]"), "//*[@numFound='0']");
183: assertQ(req("val_s:[a TO a]"), "//*[@numFound='0']");
184: assertQ(req("val_s:[apple TO apple]"), "//*[@numFound='1']");
185: assertQ(req("val_s:{apple TO pear}"), "//*[@numFound='1']");
186: assertQ(req("val_s:{a TO z}"), "//*[@numFound='3']");
187: assertQ(req("val_s:{* TO *}"), "//*[@numFound='3']");
188: // test rangequery within a boolean query
189:
190: assertQ(req("id:44 AND val_s:[a TO z]"), "//*[@numFound='3']");
191: assertQ(req("id:44 OR val_s:[a TO z]"), "//*[@numFound='3']");
192: assertQ(req("val_s:[a TO b] OR val_s:[b TO z]"),
193: "//*[@numFound='3']");
194: assertQ(req("+val_s:[a TO b] -val_s:[b TO z]"),
195: "//*[@numFound='1']");
196: assertQ(req("-val_s:[a TO b] +val_s:[b TO z]"),
197: "//*[@numFound='2']");
198: assertQ(req("val_s:[a TO c] AND val_s:[apple TO z]"),
199: "//*[@numFound='2']");
200: assertQ(req("val_s:[a TO c] AND val_s:[a TO apple]"),
201: "//*[@numFound='1']");
202: assertQ(
203: req("id:44 AND (val_s:[a TO c] AND val_s:[a TO apple])"),
204: "//*[@numFound='1']");
205: assertQ(
206: req("(val_s:[apple TO apple] OR val_s:[a TO c]) AND (val_s:[b TO c] OR val_s:[b TO b])"),
207: "//*[@numFound='1'] ", "//str[.='banana']");
208: assertQ(
209: req("(val_s:[apple TO apple] AND val_s:[a TO c]) OR (val_s:[p TO z] AND val_s:[a TO z])"),
210: "//*[@numFound='2'] ", "//str[.='apple'] ",
211: "//str[.='pear']");
212:
213: // check for docs that appear more than once in a range
214:
215: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"val_s\">apple</field><field name=\"val_s\">banana</field></doc></add>");
216: assertU("<commit/>");
217: assertQ(req("val_s:[* TO *] OR val_s:[* TO *]"),
218: "//*[@numFound='4']");
219: assertQ(req("val_s:[* TO *] AND val_s:[* TO *]"),
220: "//*[@numFound='4']");
221: assertQ(req("val_s:[* TO *]"), "//*[@numFound='4']");
222:
223: // <delete><id>44</id></delete>
224:
225: assertU("<add overwritePending=\"true\" overwriteCommitted=\"true\"><doc><field name=\"id\">44</field><field name=\"text\">red riding hood</field></doc></add>");
226: assertU("<commit/>");
227: assertQ(req("id:44 AND red"), "//@numFound[.='1'] ",
228: "*[count(//doc)=1]");
229: assertQ(req("id:44 AND ride"), "//@numFound[.='1']");
230: assertQ(req("id:44 AND blue"), "//@numFound[.='0']");
231:
232: // allow duplicates
233:
234: assertU("<delete><id>44</id></delete>");
235: assertU("<add allowDups=\"true\" overwriteCommitted=\"false\" overwritePending=\"false\"><doc><field name=\"id\">44</field><field name=\"text\">red riding hood</field></doc></add>");
236: assertU("<add allowDups=\"true\" overwriteCommitted=\"false\" overwritePending=\"false\"><doc><field name=\"id\">44</field><field name=\"text\">big bad wolf</field></doc></add>");
237: assertU("<commit/>");
238: assertQ(req("id:44"), "//@numFound[.='2']");
239: assertQ(req("id:44 AND red"), "//@numFound[.='1'] ",
240: "*[count(//doc)=1]");
241: assertQ(req("id:44 AND wolf"), "//@numFound[.='1'] ",
242: "*[count(//doc)=1]");
243: assertQ(req("+id:44 red wolf"), "//@numFound[.='2']");
244:
245: // test removal of multiples w/o adding anything else
246:
247: assertU("<delete><id>44</id></delete>");
248: assertU("<commit/>");
249: assertQ(req("id:44"), "//@numFound[.='0']");
250:
251: // untokenized string type
252:
253: assertU("<delete><id>44</id></delete>");
254: assertU("<add><doc><field name=\"id\">44</field><field name=\"ssto\">and a 10.4 ?</field></doc></add>");
255: assertU("<commit/>");
256: assertQ(req("id:44"), "//str[.='and a 10.4 ?']");
257: assertU("<delete><id>44</id></delete>");
258: assertU("<add><doc><field name=\"id\">44</field><field name=\"sind\">abc123</field></doc></add>");
259: assertU("<commit/>");
260: // TODO: how to search for something with spaces....
261:
262: assertQ(req("sind:abc123"), "//@numFound[.='1'] ",
263: "*[count(//@name[.='sind'])=0] ",
264: "*[count(//@name[.='id'])=1]");
265:
266: assertU("<delete><id>44</id></delete>");
267: assertU("<delete><id>44</id></delete>");
268: assertU("<add><doc><field name=\"id\">44</field><field name=\"sindsto\">abc123</field></doc></add>");
269: assertU("<commit/>");
270: // TODO: how to search for something with spaces....
271:
272: assertQ(req("sindsto:abc123"), "//str[.='abc123']");
273:
274: // test output of multivalued fields
275:
276: assertU("<delete><id>44</id></delete>");
277: assertU("<add><doc><field name=\"id\">44</field><field name=\"title\">yonik3</field><field name=\"title\" boost=\"2\">yonik4</field></doc></add>");
278: assertU("<commit></commit>");
279: assertQ(
280: req("id:44"),
281: "//arr[@name='title'][./str='yonik3' and ./str='yonik4'] ",
282: "*[count(//@name[.='title'])=1]");
283: assertQ(req("title:yonik3"), "//@numFound[.>'0']");
284: assertQ(req("title:yonik4"), "//@numFound[.>'0']");
285: assertQ(req("title:yonik5"), "//@numFound[.='0']");
286: assertU("<delete><query>title:yonik4</query></delete>");
287: assertU("<commit/>");
288: assertQ(req("id:44"), "//@numFound[.='0']");
289:
290: // not visible until commit
291:
292: assertU("<delete><id>44</id></delete>");
293: assertU("<commit/>");
294: assertU("<add><doc><field name=\"id\">44</field></doc></add>");
295: assertQ(req("id:44"), "//@numFound[.='0']");
296: assertU("<commit/>");
297: assertQ(req("id:44"), "//@numFound[.='1']");
298:
299: // test configurable stop words
300:
301: assertU("<delete><id>44</id></delete>");
302: assertU("<add><doc><field name=\"id\">44</field><field name=\"teststop\">world stopworda view</field></doc></add>");
303: assertU("<commit/>");
304: assertQ(req("+id:44 +teststop:world"), "//@numFound[.='1']");
305: assertQ(req("teststop:stopworda"), "//@numFound[.='0']");
306:
307: // test ignoreCase stop words
308:
309: assertU("<delete><id>44</id></delete>");
310: assertU("<add><doc><field name=\"id\">44</field><field name=\"stopfilt\">world AnD view</field></doc></add>");
311: assertU("<commit/>");
312: assertQ(req("+id:44 +stopfilt:world"), "//@numFound[.='1']");
313: assertQ(req("stopfilt:\"and\""), "//@numFound[.='0']");
314: assertQ(req("stopfilt:\"AND\""), "//@numFound[.='0']");
315: assertQ(req("stopfilt:\"AnD\""), "//@numFound[.='0']");
316:
317: // test dynamic field types
318:
319: assertU("<delete fromPending=\"true\" fromCommitted=\"true\"><id>44</id></delete>");
320: assertU("<add><doc><field name=\"id\">44</field><field name=\"gack_i\">51778</field><field name=\"t_name\">cats</field></doc></add>");
321: assertU("<commit/>");
322: // test if the dyn fields got added
323:
324: assertQ(req("id:44"), "*[count(//doc/*)>=3] ",
325: "//int[@name='gack_i'][.='51778'] ",
326: "//str[@name='t_name'][.='cats']");
327: // now test if we can query by a dynamic field (requires analyzer support)
328:
329: assertQ(req("t_name:cat"), "//str[@name='t_name' and .='cats']");
330: // check that deleteByQuery works for dynamic fields
331:
332: assertU("<delete><query>t_name:cat</query></delete>");
333: assertU("<commit/>");
334: assertQ(req("t_name:cat"), "//@numFound[.='0']");
335:
336: // test that longest dynamic field match happens first
337:
338: assertU("<add><doc><field name=\"id\">44</field><field name=\"xaa\">mystr</field><field name=\"xaaa\">12321</field></doc></add>");
339: assertU("<commit/>");
340: assertQ(req("id:44"), "//str[@name='xaa'][.='mystr'] ",
341: "//int[@name='xaaa'][.='12321']");
342:
343: // test integer ranges and sorting
344:
345: assertU("<delete><id>44</id></delete>");
346: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">1234567890</field></doc></add>");
347: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">10</field></doc></add>");
348: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">1</field></doc></add>");
349: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">2</field></doc></add>");
350: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">15</field></doc></add>");
351: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">-1</field></doc></add>");
352: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">-987654321</field></doc></add>");
353: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">2147483647</field></doc></add>");
354: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">-2147483648</field></doc></add>");
355: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_i\">0</field></doc></add>");
356: assertU("<commit/>");
357: assertQ(req("id:44"), "*[count(//doc)=10]");
358: assertQ(req("num_i:2147483647"), "//@numFound[.='1'] ",
359: "//int[.='2147483647']");
360: assertQ(req("num_i:\"-2147483648\""), "//@numFound[.='1'] ",
361: "//int[.='-2147483648']");
362: assertQ(req("id:44;num_i asc;"),
363: "//doc[1]/int[.='-2147483648'] ",
364: "//doc[last()]/int[.='2147483647']");
365: assertQ(req("id:44;num_i desc;"),
366: "//doc[1]/int[.='2147483647'] ",
367: "//doc[last()]/int[.='-2147483648']");
368: assertQ(req("num_i:[0 TO 9]"), "*[count(//doc)=3]");
369: assertQ(req("num_i:[-2147483648 TO 2147483647]"),
370: "*[count(//doc)=10]");
371: assertQ(req("num_i:[-10 TO -1]"), "*[count(//doc)=1]");
372:
373: // test long ranges and sorting
374:
375: assertU("<delete><id>44</id></delete>");
376: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">1234567890</field></doc></add>");
377: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">10</field></doc></add>");
378: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">1</field></doc></add>");
379: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">2</field></doc></add>");
380: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">15</field></doc></add>");
381: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">-1</field></doc></add>");
382: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">-987654321</field></doc></add>");
383: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">9223372036854775807</field></doc></add>");
384: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">-9223372036854775808</field></doc></add>");
385: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_l\">0</field></doc></add>");
386: assertU("<commit/>");
387: assertQ(req("id:44"), "*[count(//doc)=10]");
388: assertQ(req("num_l:9223372036854775807"),
389: "//@numFound[.='1'] ",
390: "//long[.='9223372036854775807']");
391: assertQ(req("num_l:\"-9223372036854775808\""),
392: "//@numFound[.='1'] ",
393: "//long[.='-9223372036854775808']");
394: assertQ(req("id:44;num_l asc;"),
395: "//doc[1]/long[.='-9223372036854775808'] ",
396: "//doc[last()]/long[.='9223372036854775807']");
397: assertQ(req("id:44;num_l desc;"),
398: "//doc[1]/long[.='9223372036854775807'] ",
399: "//doc[last()]/long[.='-9223372036854775808']");
400: assertQ(req("num_l:[-1 TO 9]"), "*[count(//doc)=4]");
401: assertQ(
402: req("num_l:[-9223372036854775808 TO 9223372036854775807]"),
403: "*[count(//doc)=10]");
404: assertQ(req("num_l:[-10 TO -1]"), "*[count(//doc)=1]");
405:
406: // test binary float ranges and sorting
407:
408: assertU("<delete><id>44</id></delete>");
409: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">1.4142135</field></doc></add>");
410: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">Infinity</field></doc></add>");
411: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-Infinity</field></doc></add>");
412: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">NaN</field></doc></add>");
413: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">2</field></doc></add>");
414: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-1</field></doc></add>");
415: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-987654321</field></doc></add>");
416: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-999999.99</field></doc></add>");
417: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">-1e20</field></doc></add>");
418: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_f\">0</field></doc></add>");
419: assertU("<commit/>");
420: assertQ(req("id:44"), "*[count(//doc)=10]");
421: assertQ(req("num_f:Infinity"), "//@numFound[.='1'] ",
422: "//float[.='Infinity']");
423: assertQ(req("num_f:\"-Infinity\""), "//@numFound[.='1'] ",
424: "//float[.='-Infinity']");
425: assertQ(req("num_f:\"NaN\""), "//@numFound[.='1'] ",
426: "//float[.='NaN']");
427: assertQ(req("num_f:\"-1e20\""), "//@numFound[.='1']");
428: assertQ(req("id:44;num_f asc;"),
429: "//doc[1]/float[.='-Infinity'] ",
430: "//doc[last()]/float[.='NaN']");
431: assertQ(req("id:44;num_f desc;"), "//doc[1]/float[.='NaN'] ",
432: "//doc[last()]/float[.='-Infinity']");
433: assertQ(req("num_f:[-1 TO 2]"), "*[count(//doc)=4]");
434: assertQ(req("num_f:[-Infinity TO Infinity]"),
435: "*[count(//doc)=9]");
436:
437: // test binary double ranges and sorting
438:
439: assertU("<delete><id>44</id></delete>");
440: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">1.4142135</field></doc></add>");
441: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">Infinity</field></doc></add>");
442: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-Infinity</field></doc></add>");
443: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">NaN</field></doc></add>");
444: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">2</field></doc></add>");
445: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-1</field></doc></add>");
446: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">1e-100</field></doc></add>");
447: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-999999.99</field></doc></add>");
448: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">-1e100</field></doc></add>");
449: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"num_d\">0</field></doc></add>");
450: assertU("<commit/>");
451: assertQ(req("id:44"), "*[count(//doc)=10]");
452: assertQ(req("num_d:Infinity"), "//@numFound[.='1'] ",
453: "//double[.='Infinity']");
454: assertQ(req("num_d:\"-Infinity\""), "//@numFound[.='1'] ",
455: "//double[.='-Infinity']");
456: assertQ(req("num_d:\"NaN\""), "//@numFound[.='1'] ",
457: "//double[.='NaN']");
458: assertQ(req("num_d:\"-1e100\""), "//@numFound[.='1']");
459: assertQ(req("num_d:\"1e-100\""), "//@numFound[.='1']");
460: assertQ(req("id:44;num_d asc;"),
461: "//doc[1]/double[.='-Infinity'] ",
462: "//doc[last()]/double[.='NaN']");
463: assertQ(req("id:44;num_d desc;"), "//doc[1]/double[.='NaN'] ",
464: "//doc[last()]/double[.='-Infinity']");
465: assertQ(req("num_d:[-1 TO 2]"), "*[count(//doc)=5]");
466: assertQ(req("num_d:[-Infinity TO Infinity]"),
467: "*[count(//doc)=9]");
468:
469: // test sorting on multiple fields
470:
471: assertU("<delete><id>44</id></delete>");
472: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">10</field></doc></add>");
473: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">1</field><field name=\"b_i\">100</field></doc></add>");
474: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">-1</field></doc></add>");
475: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">15</field></doc></add>");
476: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">1</field><field name=\"b_i\">50</field></doc></add>");
477: assertU("<add allowDups=\"true\"><doc><field name=\"id\">44</field><field name=\"a_i\">0</field></doc></add>");
478: assertU("<commit/>");
479: assertQ(req("id:44"), "*[count(//doc)=6]");
480:
481: assertQ(req("id:44; a_i asc,b_i desc"), "*[count(//doc)=6] ",
482: "//doc[3]/int[.='100'] ", "//doc[4]/int[.='50']");
483: assertQ(req("id:44;a_i asc , b_i asc;"), "*[count(//doc)=6] ",
484: "//doc[3]/int[.='50'] ", "//doc[4]/int[.='100']");
485: assertQ(req("id:44;a_i asc;"), "*[count(//doc)=6] ",
486: "//doc[1]/int[.='-1'] ", "//doc[last()]/int[.='15']");
487: assertQ(req("id:44;a_i asc , score top;"),
488: "*[count(//doc)=6] ", "//doc[1]/int[.='-1'] ",
489: "//doc[last()]/int[.='15']");
490: assertQ(req("id:44; score top , a_i top, b_i bottom ;"),
491: "*[count(//doc)=6] ", "//doc[last()]/int[.='-1'] ",
492: "//doc[1]/int[.='15'] ", "//doc[3]/int[.='50'] ",
493: "//doc[4]/int[.='100']");
494:
495: // test sorting with some docs missing the sort field
496:
497: assertU("<delete><query>id_i:[1000 TO 1010]</query></delete>");
498: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1000</field><field name=\"a_i\">1</field><field name=\"nullfirst\">Z</field></doc></add>");
499: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1001</field><field name=\"a_i\">10</field><field name=\"nullfirst\">A</field></doc></add>");
500: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1002</field><field name=\"a_i\">1</field><field name=\"b_i\">100</field></doc></add>");
501: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1003</field><field name=\"a_i\">-1</field></doc></add>");
502: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1004</field><field name=\"a_i\">15</field></doc></add>");
503: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1005</field><field name=\"a_i\">1</field><field name=\"b_i\">50</field></doc></add>");
504: assertU("<add allowDups=\"true\"><doc><field name=\"id_i\">1006</field><field name=\"a_i\">0</field></doc></add>");
505: assertU("<commit/>");
506: assertQ(req("id_i:[1000 TO 1010]"), "*[count(//doc)=7]");
507: assertQ(req("id_i:[1000 TO 1010]; b_i asc"),
508: "*[count(//doc)=7] ", "//doc[1]/int[.='50'] ",
509: "//doc[2]/int[.='100']");
510: assertQ(req("id_i:[1000 TO 1010]; b_i desc"),
511: "*[count(//doc)=7] ", "//doc[1]/int[.='100'] ",
512: "//doc[2]/int[.='50']");
513: assertQ(req("id_i:[1000 TO 1010]; a_i asc,b_i desc"),
514: "*[count(//doc)=7] ", "//doc[3]/int[.='100'] ",
515: "//doc[4]/int[.='50'] ", "//doc[5]/int[.='1000']");
516: assertQ(req("id_i:[1000 TO 1010]; a_i asc,b_i asc"),
517: "*[count(//doc)=7] ", "//doc[3]/int[.='50'] ",
518: "//doc[4]/int[.='100'] ", "//doc[5]/int[.='1000']");
519: // nullfirst tests
520: assertQ(req("id_i:[1000 TO 1002]; nullfirst asc"),
521: "*[count(//doc)=3] ", "//doc[1]/int[.='1002']",
522: "//doc[2]/int[.='1001'] ", "//doc[3]/int[.='1000']");
523: assertQ(req("id_i:[1000 TO 1002]; nullfirst desc"),
524: "*[count(//doc)=3] ", "//doc[1]/int[.='1002']",
525: "//doc[2]/int[.='1000'] ", "//doc[3]/int[.='1001']");
526:
527: // Sort parsing exception tests. (SOLR-6, SOLR-99)
528: assertQEx("can not sort unindexed fields",
529: req("id_i:1000; shouldbeunindexed asc"), 400);
530:
531: assertQEx("invalid query format", req("id_i:1000; nullfirst"),
532: 400);
533:
534: assertQEx("unknown sort field",
535: req("id_i:1000; abcde12345 asc"), 400);
536:
537: assertQEx("unknown sort order",
538: req("id_i:1000; nullfirst aaa"), 400);
539:
540: // test prefix query
541:
542: assertU("<delete><query>val_s:[* TO *]</query></delete>");
543: assertU("<add><doc><field name=\"id\">100</field><field name=\"val_s\">apple</field></doc></add>");
544: assertU("<add><doc><field name=\"id\">101</field><field name=\"val_s\">banana</field></doc></add>");
545: assertU("<add><doc><field name=\"id\">102</field><field name=\"val_s\">apple</field></doc></add>");
546: assertU("<add><doc><field name=\"id\">103</field><field name=\"val_s\">pearing</field></doc></add>");
547: assertU("<add><doc><field name=\"id\">104</field><field name=\"val_s\">pear</field></doc></add>");
548: assertU("<add><doc><field name=\"id\">105</field><field name=\"val_s\">appalling</field></doc></add>");
549: assertU("<add><doc><field name=\"id\">106</field><field name=\"val_s\">pearson</field></doc></add>");
550: assertU("<add><doc><field name=\"id\">107</field><field name=\"val_s\">port</field></doc></add>");
551: assertU("<commit/>");
552:
553: assertQ(req("val_s:a*"), "//*[@numFound='3']");
554: assertQ(req("val_s:p*"), "//*[@numFound='4']");
555: // val_s:* %//*[@numFound="8"]
556:
557: assertU("<delete><query>id:[100 TO 110]</query></delete>");
558:
559: // test copyField functionality
560:
561: assertU("<add><doc><field name=\"id\">42</field><field name=\"title\">How Now4 brown Cows</field></doc></add>");
562: assertU("<commit/>");
563: assertQ(req("id:42 AND title:Now"), "*[count(//doc)=0]");
564: assertQ(req("id:42 AND title_lettertok:Now"),
565: "*[count(//doc)=1]");
566: assertQ(req("id:42 AND title:cow"), "*[count(//doc)=0]");
567: assertQ(req("id:42 AND title_stemmed:cow"), "*[count(//doc)=1]");
568: assertQ(req("id:42 AND text:cow"), "*[count(//doc)=1]");
569:
570: // test copyField functionality with a pattern.
571:
572: assertU("<add><doc><field name=\"id\">42</field><field name=\"copy_t\">Copy me to the text field pretty please.</field></doc></add>");
573: assertU("<commit/>");
574: assertQ(req("id:42 AND text:pretty"), "*[count(//doc)=1]");
575: assertQ(req("id:42 AND copy_t:pretty"), "*[count(//doc)=1]");
576:
577: // test slop
578:
579: assertU("<add><doc><field name=\"id\">42</field><field name=\"text\">foo bar</field></doc></add>");
580: assertU("<commit/>");
581: assertQ(req("id:42 AND text:\"foo bar\""), "*[count(//doc)=1]");
582: assertQ(req("id:42 AND text:\"foo\""), "*[count(//doc)=1]");
583: assertQ(req("id:42 AND text:\"bar\""), "*[count(//doc)=1]");
584: assertQ(req("id:42 AND text:\"bar foo\""), "*[count(//doc)=0]");
585: assertQ(req("id:42 AND text:\"bar foo\"~2"),
586: "*[count(//doc)=1]");
587:
588: // intra-word delimiter testing (WordDelimiterFilter)
589:
590: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">foo bar</field></doc></add>");
591: assertU("<commit/>");
592: assertQ(req("id:42 AND subword:\"foo bar\""),
593: "*[count(//doc)=1]");
594: assertQ(req("id:42 AND subword:\"foo\""), "*[count(//doc)=1]");
595: assertQ(req("id:42 AND subword:\"bar\""), "*[count(//doc)=1]");
596: assertQ(req("id:42 AND subword:\"bar foo\""),
597: "*[count(//doc)=0]");
598: assertQ(req("id:42 AND subword:\"bar foo\"~2"),
599: "*[count(//doc)=1]");
600: assertQ(req("id:42 AND subword:\"foo/bar\""),
601: "*[count(//doc)=1]");
602: assertQ(req("id:42 AND subword:\"foobar\""),
603: "*[count(//doc)=0]");
604:
605: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">foo-bar</field></doc></add>");
606: assertU("<commit/>");
607: assertQ(req("id:42 AND subword:\"foo bar\""),
608: "*[count(//doc)=1]");
609: assertQ(req("id:42 AND subword:\"foo\""), "*[count(//doc)=1]");
610: assertQ(req("id:42 AND subword:\"bar\""), "*[count(//doc)=1]");
611: assertQ(req("id:42 AND subword:\"bar foo\""),
612: "*[count(//doc)=0]");
613: assertQ(req("id:42 AND subword:\"bar foo\"~2"),
614: "*[count(//doc)=1]");
615: assertQ(req("id:42 AND subword:\"foo/bar\""),
616: "*[count(//doc)=1]");
617: assertQ(req("id:42 AND subword:foobar"), "*[count(//doc)=1]");
618:
619: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">Canon PowerShot SD500 7MP</field></doc></add>");
620: assertU("<commit/>");
621: assertQ(req("id:42 AND subword:\"power-shot\""),
622: "*[count(//doc)=1]");
623: assertQ(req("id:42 AND subword:\"power shot sd 500\""),
624: "*[count(//doc)=1]");
625: assertQ(req("id:42 AND subword:\"powershot\""),
626: "*[count(//doc)=1]");
627: assertQ(req("id:42 AND subword:\"SD-500\""),
628: "*[count(//doc)=1]");
629: assertQ(req("id:42 AND subword:\"SD500\""), "*[count(//doc)=1]");
630: assertQ(req("id:42 AND subword:\"SD500-7MP\""),
631: "*[count(//doc)=1]");
632: assertQ(req("id:42 AND subword:\"PowerShotSD500-7MP\""),
633: "*[count(//doc)=1]");
634:
635: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">Wi-Fi</field></doc></add>");
636: assertU("<commit/>");
637: assertQ(req("id:42 AND subword:wifi"), "*[count(//doc)=1]");
638: assertQ(req("id:42 AND subword:wi+=fi"), "*[count(//doc)=1]");
639: assertQ(req("id:42 AND subword:wi+=fi"), "*[count(//doc)=1]");
640: assertQ(req("id:42 AND subword:WiFi"), "*[count(//doc)=1]");
641: assertQ(req("id:42 AND subword:\"wi fi\""), "*[count(//doc)=1]");
642:
643: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">'I.B.M' A's,B's,C's</field></doc></add>");
644: assertU("<commit/>");
645: assertQ(req("id:42 AND subword:\"'I.B.M.'\""),
646: "*[count(//doc)=1]");
647: assertQ(req("id:42 AND subword:I.B.M"), "*[count(//doc)=1]");
648: assertQ(req("id:42 AND subword:IBM"), "*[count(//doc)=1]");
649: assertQ(req("id:42 AND subword:I--B--M"), "*[count(//doc)=1]");
650: assertQ(req("id:42 AND subword:\"I B M\""), "*[count(//doc)=1]");
651: assertQ(req("id:42 AND subword:IBM's"), "*[count(//doc)=1]");
652: assertQ(req("id:42 AND subword:IBM'sx"), "*[count(//doc)=0]");
653:
654: // this one fails since IBM and ABC are separated by two tokens
655:
656: // id:42 AND subword:IBM's-ABC's %*[count(//doc)=1]
657:
658: assertQ(req("id:42 AND subword:\"IBM's-ABC's\"~2"),
659: "*[count(//doc)=1]");
660:
661: assertQ(req("id:42 AND subword:\"A's B's-C's\""),
662: "*[count(//doc)=1]");
663:
664: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">Sony KDF-E50A10</field></doc></add>");
665: assertU("<commit/>");
666:
667: // check for exact match:
668:
669: // Sony KDF E/KDFE 50 A 10 (this is how it's indexed)
670:
671: // Sony KDF E 50 A 10 (and how it's queried)
672:
673: assertQ(req("id:42 AND subword:\"Sony KDF-E50A10\""),
674: "*[count(//doc)=1]");
675: assertQ(req("id:42 AND subword:10"), "*[count(//doc)=1]");
676: assertQ(req("id:42 AND subword:Sony"), "*[count(//doc)=1]");
677:
678: // this one fails without slop since Sony and KDFE have a token inbetween
679:
680: // id:42 AND subword:SonyKDFE50A10 %*[count(//doc)=1]
681:
682: assertQ(req("id:42 AND subword:\"SonyKDFE50A10\"~10"),
683: "*[count(//doc)=1]");
684:
685: assertQ(req("id:42 AND subword:\"Sony KDF E-50-A-10\""),
686: "*[count(//doc)=1]");
687:
688: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">http://www.yahoo.com</field></doc></add>");
689: assertU("<commit/>");
690: assertQ(req("id:42 AND subword:yahoo"), "*[count(//doc)=1]");
691: assertQ(req("id:42 AND subword:www.yahoo.com"),
692: "*[count(//doc)=1]");
693: assertQ(req("id:42 AND subword:http\\://www.yahoo.com"),
694: "*[count(//doc)=1]");
695:
696: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">--Q 1-- W2 E-3 Ok xY 4R 5-T *6-Y- 7-8-- 10A-B</field></doc></add>");
697: assertU("<commit/>");
698: assertQ(req("id:42 AND subword:Q"), "*[count(//doc)=1]");
699: assertQ(req("id:42 AND subword:1"), "*[count(//doc)=1]");
700: assertQ(req("id:42 AND subword:\"w 2\""), "*[count(//doc)=1]");
701: assertQ(req("id:42 AND subword:\"e 3\""), "*[count(//doc)=1]");
702: assertQ(req("id:42 AND subword:\"o k\""), "*[count(//doc)=0]");
703: assertQ(req("id:42 AND subword:\"ok\""), "*[count(//doc)=1]");
704: assertQ(req("id:42 AND subword:\"x y\""), "*[count(//doc)=1]");
705: assertQ(req("id:42 AND subword:\"xy\""), "*[count(//doc)=1]");
706: assertQ(req("id:42 AND subword:\"4 r\""), "*[count(//doc)=1]");
707: assertQ(req("id:42 AND subword:\"5 t\""), "*[count(//doc)=1]");
708: assertQ(req("id:42 AND subword:\"5 t\""), "*[count(//doc)=1]");
709: assertQ(req("id:42 AND subword:\"6 y\""), "*[count(//doc)=1]");
710: assertQ(req("id:42 AND subword:\"7 8\""), "*[count(//doc)=1]");
711: assertQ(req("id:42 AND subword:\"78\""), "*[count(//doc)=1]");
712: assertQ(req("id:42 AND subword:\"10 A+B\""),
713: "*[count(//doc)=1]");
714:
715: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">FooBarBaz</field></doc></add>");
716: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">FooBar10</field></doc></add>");
717: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">10FooBar</field></doc></add>");
718: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">BAZ</field></doc></add>");
719: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">10</field></doc></add>");
720: assertU("<add><doc><field name=\"id\">42</field><field name=\"subword\">Mark, I found what's the problem! It turns to be from the latest schema. I found tons of exceptions in the resin.stdout that prevented the builder from performing. It's all coming from the WordDelimiterFilter which was just added to the latest schema: [2005-08-29 15:11:38.375] java.lang.IndexOutOfBoundsException: Index: 3, Size: 3 673804 [2005-08-29 15:11:38.375] at java.util.ArrayList.RangeCheck(ArrayList.java:547) 673805 [2005-08-29 15:11:38.375] at java.util.ArrayList.get(ArrayList.java:322) 673806 [2005-08-29 15:11:38.375] at solr.analysis.WordDelimiterFilter.addCombos(WordDelimiterFilter.java:349) 673807 [2005-08-29 15:11:38.375] at solr.analysis.WordDelimiterFilter.next(WordDelimiterFilter.java:325) 673808 [2005-08-29 15:11:38.375] at org.apache.lucene.analysis.LowerCaseFilter.next(LowerCaseFilter.java:32) 673809 [2005-08-29 15:11:38.375] at org.apache.lucene.analysis.StopFilter.next(StopFilter.java:98) 673810 [2005-08-29 15:11:38.375] at solr.EnglishPorterFilter.next(TokenizerFactory.java:163) 673811 [2005-08-29 15:11:38.375] at org.apache.lucene.index.DocumentWriter.invertDocument(DocumentWriter.java:143) 673812 [2005-08-29 15:11:38.375] at org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:81) 673813 [2005-08-29 15:11:38.375] at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:307) 673814 [2005-08-29 15:11:38.375] at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:294) 673815 [2005-08-29 15:11:38.375] at solr.DirectUpdateHandler2.doAdd(DirectUpdateHandler2.java:170) 673816 [2005-08-29 15:11:38.375] at solr.DirectUpdateHandler2.overwriteBoth(DirectUpdateHandler2.java:317) 673817 [2005-08-29 15:11:38.375] at solr.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:191) 673818 [2005-08-29 15:11:38.375] at solr.SolrCore.update(SolrCore.java:795) 673819 [2005-08-29 15:11:38.375] at solrserver.SolrServlet.doPost(SolrServlet.java:71) 673820 [2005-08-29 15:11:38.375] at javax.servlet.http.HttpServlet.service(HttpServlet.java:154) 673821 [2005-08-29 15:11:38.375] at javax.servlet.http.HttpServlet.service(HttpServlet.java:92) 673822 [2005-08-29 15:11:38.375] at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99) 673823 [2005-08-29 15:11:38.375] at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:188) 673824 [2005-08-29 15:11:38.375] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163) 673825 [2005-08-29 15:11:38.375] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208) 673826 [2005-08-29 15:11:38.375] at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259) 673827 [2005-08-29 15:11:38.375] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363) 673828 [2005-08-29 15:11:38.375] at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490) 673829 [2005-08-29 15:11:38.375] at com.caucho.util.ThreadPool.run(ThreadPool.java:423) 673830 [2005-08-29 15:11:38.375] at java.lang.Thread.run(Thread.java:595) With the previous schema I'm able to perform a successful full build: http://c12-ssa-dev40-so-mas1.cnet.com:5078/select/?stylesheet=q=docTypeversion=2.0start=0rows=10indent=on Do you want to rollback to the previous schema version</field></doc></add>");
721:
722: //
723:
724: assertU("<delete fromPending=\"true\" fromCommitted=\"true\"><id>44</id></delete>");
725: assertU("<add><doc><field name=\"id\">44</field><field name=\"fname_s\">Yonik</field><field name=\"here_b\">true</field><field name=\"iq_l\">10000000000</field><field name=\"description_t\">software engineer</field><field name=\"ego_d\">1e100</field><field name=\"pi_f\">3.1415962</field><field name=\"when_dt\">2005-03-18T01:14:34Z</field><field name=\"arr_f\">1.414213562</field><field name=\"arr_f\">.999</field></doc></add>");
726: assertU("<commit/>");
727: assertQ(req("id:44"));
728: args = new HashMap<String, String>();
729: args.put("version", "2.0");
730: args.put("fl", "fname_s,arr_f ");
731: req = new LocalSolrQueryRequest(h.getCore(), "id:44",
732: "standard", 0, 10, args);
733: assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135']");
734: args = new HashMap<String, String>();
735: args.put("version", "2.0");
736: args.put("fl", " ");
737: req = new LocalSolrQueryRequest(h.getCore(), "id:44",
738: "standard", 0, 10, args);
739: assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135']");
740:
741: // test addition of score field
742:
743: args = new HashMap<String, String>();
744: args.put("version", "2.0");
745: args.put("fl", "score ");
746: req = new LocalSolrQueryRequest(h.getCore(), "id:44",
747: "standard", 0, 10, args);
748: assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135'] ",
749: "//float[@name='score'] ", "*[count(//doc/*)=13]");
750: args = new HashMap<String, String>();
751: args.put("version", "2.0");
752: args.put("fl", "*,score ");
753: req = new LocalSolrQueryRequest(h.getCore(), "id:44",
754: "standard", 0, 10, args);
755: assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135'] ",
756: "//float[@name='score'] ", "*[count(//doc/*)=13]");
757: args = new HashMap<String, String>();
758: args.put("version", "2.0");
759: args.put("fl", "* ");
760: req = new LocalSolrQueryRequest(h.getCore(), "id:44",
761: "standard", 0, 10, args);
762: assertQ(req, "//str[.='Yonik'] ", "//float[.='1.4142135'] ",
763: "*[count(//doc/*)>=12]");
764:
765: // test maxScore
766:
767: args = new HashMap<String, String>();
768: args.put("version", "2.0");
769: args.put("fl", "score ");
770: req = new LocalSolrQueryRequest(h.getCore(), "id:44",
771: "standard", 0, 10, args);
772: assertQ(req, "//result[@maxScore>0]");
773: args = new HashMap<String, String>();
774: args.put("version", "2.0");
775: args.put("fl", "score ");
776: req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",
777: "standard", 0, 10, args);
778: assertQ(req, "//result[@maxScore>0]");
779: args = new HashMap<String, String>();
780: args.put("version", "2.0");
781: args.put("fl", "score ");
782: req = new LocalSolrQueryRequest(h.getCore(), "id:44;",
783: "standard", 0, 10, args);
784: assertQ(req, "//@maxScore = //doc/float[@name='score']");
785: args = new HashMap<String, String>();
786: args.put("version", "2.0");
787: args.put("fl", "score ");
788: req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",
789: "standard", 0, 10, args);
790: assertQ(req, "//@maxScore = //doc/float[@name='score']");
791: args = new HashMap<String, String>();
792: args.put("version", "2.0");
793: args.put("fl", "score");
794: req = new LocalSolrQueryRequest(h.getCore(), "id:44;id desc;",
795: "standard", 0, 0, args);
796: assertQ(req, "//result[@maxScore>0]");
797:
798: // test schema field attribute inheritance and overriding
799:
800: assertU("<delete><id>44</id></delete>");
801: assertU("<add><doc><field name=\"id\">44</field><field name=\"shouldbestored\">hi</field></doc></add>");
802: assertU("<commit/>");
803: assertQ(req("id:44"), "//*[@name='shouldbestored']");
804: assertQ(req("+id:44 +shouldbestored:hi"), "//*[@numFound='1']");
805:
806: assertU("<delete><id>44</id></delete>");
807: assertU("<add><doc><field name=\"id\">44</field><field name=\"shouldbeunstored\">hi</field></doc></add>");
808: assertU("<commit/>");
809: assertQ(req("id:44"), "not(//*[@name='shouldbeunstored'])");
810: assertQ(req("+id:44 +shouldbeunstored:hi"),
811: "//*[@numFound='1']");
812:
813: assertU("<delete><id>44</id></delete>");
814: assertU("<add><doc><field name=\"id\">44</field><field name=\"shouldbeunindexed\">hi</field></doc></add>");
815: assertU("<commit/>");
816: assertQ(req("id:44"), "//*[@name='shouldbeunindexed']");
817: // this should result in an error... how to check for that?
818:
819: // +id:44 +shouldbeunindexed:hi %//*[@numFound="0"]
820:
821: // test spaces between XML elements because that can introduce extra XML events that
822:
823: // can mess up parsing (and it has in the past)
824:
825: assertU(" <delete> <id>44</id> </delete>");
826: assertU(" <add> <doc> <field name=\"id\">44</field> <field name=\"shouldbestored\">hi</field> </doc> </add>");
827: assertU(" <commit />");
828:
829: // test adding multiple docs per add command
830:
831: // assertU("<delete><query>id:[0 TO 99]</query></delete>");
832: // assertU("<add><doc><field name=\"id\">1</field></doc><doc><field name=\"id\">2</field></doc></add>");
833: // assertU("<commit/>");
834: // assertQ(req("id:[0 TO 99]")
835: // ,"//*[@numFound='2']"
836: // );
837:
838: // test synonym filter
839:
840: assertU("<delete><query>id:[10 TO 100]</query></delete>");
841: assertU("<add><doc><field name=\"id\">10</field><field name=\"syn\">a</field></doc></add>");
842: assertU("<add><doc><field name=\"id\">11</field><field name=\"syn\">b</field></doc></add>");
843: assertU("<add><doc><field name=\"id\">12</field><field name=\"syn\">c</field></doc></add>");
844: assertU("<add><doc><field name=\"id\">13</field><field name=\"syn\">foo</field></doc></add>");
845: assertU("<commit/>");
846: assertQ(req("id:10 AND syn:a"), "//*[@numFound='1']");
847: assertQ(req("id:10 AND syn:aa"), "//*[@numFound='1']");
848: assertQ(req("id:11 AND syn:b"), "//*[@numFound='1']");
849: assertQ(req("id:11 AND syn:b1"), "//*[@numFound='1']");
850: assertQ(req("id:11 AND syn:b2"), "//*[@numFound='1']");
851: assertQ(req("id:12 AND syn:c"), "//*[@numFound='1']");
852: assertQ(req("id:12 AND syn:c1"), "//*[@numFound='1']");
853: assertQ(req("id:12 AND syn:c2"), "//*[@numFound='1']");
854: assertQ(req("id:13 AND syn:foo"), "//*[@numFound='1']");
855: assertQ(req("id:13 AND syn:bar"), "//*[@numFound='1']");
856: assertQ(req("id:13 AND syn:baz"), "//*[@numFound='1']");
857:
858: // test position increment gaps between field values
859:
860: assertU("<delete><id>44</id></delete>");
861: assertU("<delete><id>45</id></delete>");
862: assertU("<add><doc><field name=\"id\">44</field><field name=\"textgap\">aa bb cc</field><field name=\"textgap\">dd ee ff</field></doc></add>");
863: assertU("<add><doc><field name=\"id\">45</field><field name=\"text\">aa bb cc</field><field name=\"text\">dd ee ff</field></doc></add>");
864: assertU("<commit/>");
865: assertQ(req("+id:44 +textgap:\"aa bb cc\""),
866: "//*[@numFound='1']");
867: assertQ(req("+id:44 +textgap:\"dd ee ff\""),
868: "//*[@numFound='1']");
869: assertQ(req("+id:44 +textgap:\"cc dd\""), "//*[@numFound='0']");
870: assertQ(req("+id:44 +textgap:\"cc dd\"~100"),
871: "//*[@numFound='1']");
872: assertQ(req("+id:44 +textgap:\"bb cc dd ee\"~90"),
873: "//*[@numFound='0']");
874: assertQ(req("+id:44 +textgap:\"bb cc dd ee\"~100"),
875: "//*[@numFound='1']");
876: assertQ(req("+id:45 +text:\"cc dd\""), "//*[@numFound='1']");
877:
878: // trigger output of custom value test
879:
880: args = new HashMap<String, String>();
881: args.put("version", "2.0");
882: req = new LocalSolrQueryRequest(h.getCore(), "values", "test",
883: 0, 10, args);
884: assertQ(req);
885:
886: }
887: }
|