ferret 0.10.8 → 0.10.9
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/index.c +1 -1
- data/ext/q_parser.c +138 -127
- data/ext/r_index.c +37 -8
- data/ext/r_store.c +1 -1
- data/lib/ferret/index.rb +3 -3
- data/lib/ferret_version.rb +1 -1
- data/test/unit/query_parser/tc_query_parser.rb +2 -2
- data/test/unit/utils/tc_number_tools.rb +6 -6
- metadata +2 -2
data/ext/index.c
CHANGED
@@ -4809,7 +4809,7 @@ static int sm_append_postings(SegmentMerger *sm, SegmentMergeInfo **matches,
|
|
4809
4809
|
}
|
4810
4810
|
|
4811
4811
|
/* copy position deltas */
|
4812
|
-
|
4812
|
+
is2os_copy_vints(STDE(tde)->prx_in, sm->prx_out, freq);
|
4813
4813
|
}
|
4814
4814
|
}
|
4815
4815
|
return df;
|
data/ext/q_parser.c
CHANGED
@@ -349,18 +349,18 @@ union yyalloc
|
|
349
349
|
#endif
|
350
350
|
|
351
351
|
/* YYFINAL -- State number of the termination state. */
|
352
|
-
#define YYFINAL
|
352
|
+
#define YYFINAL 39
|
353
353
|
/* YYLAST -- Last index in YYTABLE. */
|
354
|
-
#define YYLAST
|
354
|
+
#define YYLAST 126
|
355
355
|
|
356
356
|
/* YYNTOKENS -- Number of terminals. */
|
357
357
|
#define YYNTOKENS 26
|
358
358
|
/* YYNNTS -- Number of nonterminals. */
|
359
359
|
#define YYNNTS 16
|
360
360
|
/* YYNRULES -- Number of rules. */
|
361
|
-
#define YYNRULES
|
361
|
+
#define YYNRULES 51
|
362
362
|
/* YYNRULES -- Number of states. */
|
363
|
-
#define YYNSTATES
|
363
|
+
#define YYNSTATES 80
|
364
364
|
|
365
365
|
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
366
366
|
#define YYUNDEFTOK 2
|
@@ -407,11 +407,11 @@ static const unsigned char yytranslate[] =
|
|
407
407
|
static const unsigned char yyprhs[] =
|
408
408
|
{
|
409
409
|
0, 0, 3, 4, 6, 8, 12, 16, 19, 22,
|
410
|
-
25, 27, 29, 33, 35,
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
410
|
+
25, 27, 29, 33, 35, 38, 42, 44, 46, 48,
|
411
|
+
50, 52, 56, 59, 61, 62, 67, 68, 69, 75,
|
412
|
+
77, 81, 85, 91, 94, 99, 101, 104, 107, 111,
|
413
|
+
115, 120, 125, 130, 135, 139, 143, 147, 151, 154,
|
414
|
+
158, 162
|
415
415
|
};
|
416
416
|
|
417
417
|
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
@@ -420,31 +420,31 @@ static const yysigned_char yyrhs[] =
|
|
420
420
|
27, 0, -1, -1, 28, -1, 29, -1, 28, 7,
|
421
421
|
29, -1, 28, 6, 29, -1, 28, 29, -1, 9,
|
422
422
|
30, -1, 8, 30, -1, 30, -1, 31, -1, 31,
|
423
|
-
12, 3, -1, 32, -1, 13,
|
424
|
-
-1,
|
425
|
-
|
426
|
-
10, 31, 35, -1, -1, -1, 16,
|
427
|
-
37, -1, 3, -1, 38, 17, 3,
|
428
|
-
|
429
|
-
-1, 18, 18, 15, 3, -1, 3,
|
430
|
-
-1,
|
431
|
-
|
432
|
-
23, -1, 24, 3, 3, 22, -1,
|
433
|
-
|
434
|
-
|
435
|
-
-1, 19,
|
436
|
-
3, -1
|
423
|
+
12, 3, -1, 32, -1, 13, 14, -1, 13, 28,
|
424
|
+
14, -1, 34, -1, 39, -1, 41, -1, 33, -1,
|
425
|
+
3, -1, 3, 15, 3, -1, 3, 15, -1, 4,
|
426
|
+
-1, -1, 38, 10, 31, 35, -1, -1, -1, 16,
|
427
|
+
36, 10, 31, 37, -1, 3, -1, 38, 17, 3,
|
428
|
+
-1, 18, 40, 18, -1, 18, 40, 18, 15, 3,
|
429
|
+
-1, 18, 18, -1, 18, 18, 15, 3, -1, 3,
|
430
|
+
-1, 19, 20, -1, 40, 3, -1, 40, 19, 20,
|
431
|
+
-1, 40, 17, 3, -1, 21, 3, 3, 22, -1,
|
432
|
+
21, 3, 3, 23, -1, 24, 3, 3, 22, -1,
|
433
|
+
24, 3, 3, 23, -1, 19, 3, 23, -1, 19,
|
434
|
+
3, 22, -1, 21, 3, 20, -1, 24, 3, 20,
|
435
|
+
-1, 19, 3, -1, 19, 25, 3, -1, 20, 25,
|
436
|
+
3, -1, 20, 3, -1
|
437
437
|
};
|
438
438
|
|
439
439
|
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
440
440
|
static const unsigned char yyrline[] =
|
441
441
|
{
|
442
442
|
0, 102, 102, 103, 105, 106, 107, 108, 110, 111,
|
443
|
-
112, 114, 115, 117, 118, 119, 120, 121, 122,
|
444
|
-
125, 126,
|
445
|
-
|
443
|
+
112, 114, 115, 117, 118, 119, 120, 121, 122, 123,
|
444
|
+
125, 126, 127, 129, 131, 131, 133, 133, 133, 136,
|
445
|
+
137, 139, 140, 141, 142, 144, 145, 146, 147, 148,
|
446
446
|
150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
447
|
-
160
|
447
|
+
160, 161
|
448
448
|
};
|
449
449
|
#endif
|
450
450
|
|
@@ -476,22 +476,22 @@ static const unsigned short int yytoknum[] =
|
|
476
476
|
static const unsigned char yyr1[] =
|
477
477
|
{
|
478
478
|
0, 26, 27, 27, 28, 28, 28, 28, 29, 29,
|
479
|
-
29, 30, 30, 31, 31, 31, 31, 31, 31,
|
480
|
-
32, 32, 33, 35, 34, 36, 37, 34, 38,
|
481
|
-
39, 39, 39, 39, 40, 40, 40, 40, 40,
|
479
|
+
29, 30, 30, 31, 31, 31, 31, 31, 31, 31,
|
480
|
+
32, 32, 32, 33, 35, 34, 36, 37, 34, 38,
|
481
|
+
38, 39, 39, 39, 39, 40, 40, 40, 40, 40,
|
482
482
|
41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
|
483
|
-
41
|
483
|
+
41, 41
|
484
484
|
};
|
485
485
|
|
486
486
|
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
487
487
|
static const unsigned char yyr2[] =
|
488
488
|
{
|
489
489
|
0, 2, 0, 1, 1, 3, 3, 2, 2, 2,
|
490
|
-
1, 1, 3, 1,
|
491
|
-
3, 2, 1, 0, 4, 0, 0, 5, 1,
|
492
|
-
3, 5, 2, 4, 1, 2, 2, 3, 3,
|
493
|
-
4, 4, 4, 3, 3, 3, 3, 2, 3,
|
494
|
-
2
|
490
|
+
1, 1, 3, 1, 2, 3, 1, 1, 1, 1,
|
491
|
+
1, 3, 2, 1, 0, 4, 0, 0, 5, 1,
|
492
|
+
3, 3, 5, 2, 4, 1, 2, 2, 3, 3,
|
493
|
+
4, 4, 4, 4, 3, 3, 3, 3, 2, 3,
|
494
|
+
3, 2
|
495
495
|
};
|
496
496
|
|
497
497
|
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
|
@@ -499,76 +499,82 @@ static const unsigned char yyr2[] =
|
|
499
499
|
means the default is an error. */
|
500
500
|
static const unsigned char yydefact[] =
|
501
501
|
{
|
502
|
-
2,
|
503
|
-
0, 0, 0, 3, 4, 10, 11, 13,
|
504
|
-
0,
|
505
|
-
|
506
|
-
0, 7, 0, 0, 0,
|
507
|
-
36, 0,
|
508
|
-
|
509
|
-
|
502
|
+
2, 20, 23, 0, 0, 0, 26, 0, 0, 0,
|
503
|
+
0, 0, 0, 3, 4, 10, 11, 13, 19, 16,
|
504
|
+
0, 17, 18, 22, 9, 8, 14, 0, 0, 35,
|
505
|
+
33, 0, 0, 48, 0, 51, 0, 0, 0, 1,
|
506
|
+
0, 0, 7, 0, 0, 0, 21, 15, 0, 0,
|
507
|
+
36, 37, 0, 31, 0, 45, 44, 49, 50, 0,
|
508
|
+
46, 0, 47, 6, 5, 12, 24, 30, 27, 34,
|
509
|
+
39, 0, 38, 40, 41, 42, 43, 25, 28, 32
|
510
510
|
};
|
511
511
|
|
512
512
|
/* YYDEFGOTO[NTERM-NUM]. */
|
513
513
|
static const yysigned_char yydefgoto[] =
|
514
514
|
{
|
515
|
-
-1, 12, 13, 14, 15, 16, 17, 18, 19,
|
516
|
-
|
515
|
+
-1, 12, 13, 14, 15, 16, 17, 18, 19, 77,
|
516
|
+
28, 78, 20, 21, 32, 22
|
517
517
|
};
|
518
518
|
|
519
519
|
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
520
520
|
STATE-NUM. */
|
521
|
-
#define YYPACT_NINF -
|
521
|
+
#define YYPACT_NINF -30
|
522
522
|
static const yysigned_char yypact[] =
|
523
523
|
{
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
-
|
530
|
-
|
531
|
-
|
524
|
+
83, -4, -30, 102, 102, 64, -30, 7, -2, -1,
|
525
|
+
6, 15, 31, 45, -30, -30, 29, -30, -30, -30,
|
526
|
+
-5, -30, -30, 40, -30, -30, -30, 26, 47, -30,
|
527
|
+
55, 42, 19, -15, 68, -30, 71, 0, 1, -30,
|
528
|
+
83, 83, -30, 72, 102, 73, -30, -30, 102, 76,
|
529
|
+
-30, -30, 78, 74, 70, -30, -30, -30, -30, -6,
|
530
|
+
-30, 33, -30, -30, -30, -30, -30, -30, -30, -30,
|
531
|
+
-30, 90, -30, -30, -30, -30, -30, -30, -30, -30
|
532
532
|
};
|
533
533
|
|
534
534
|
/* YYPGOTO[NTERM-NUM]. */
|
535
535
|
static const yysigned_char yypgoto[] =
|
536
536
|
{
|
537
|
-
-
|
538
|
-
-
|
537
|
+
-30, -30, 89, -13, 56, -29, -30, -30, -30, -30,
|
538
|
+
-30, -30, -30, -30, -30, -30
|
539
539
|
};
|
540
540
|
|
541
541
|
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
542
542
|
positive, shift that token. If negative, reduce the rule which
|
543
543
|
number is the opposite. If zero, do what YYDEFACT says.
|
544
544
|
If YYTABLE_NINF, syntax error. */
|
545
|
-
#define YYTABLE_NINF -
|
545
|
+
#define YYTABLE_NINF -30
|
546
546
|
static const yysigned_char yytable[] =
|
547
547
|
{
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
548
|
+
42, 33, 35, 59, 61, 44, -29, 55, 56, 37,
|
549
|
+
29, 23, 45, -29, 42, 66, 73, 74, 38, 68,
|
550
|
+
60, 62, 51, 34, 36, 30, 31, 63, 64, 1,
|
551
|
+
2, 39, 40, 41, 3, 4, 52, 53, 54, 5,
|
552
|
+
47, 43, 6, 46, 7, 8, 9, 10, 1, 2,
|
553
|
+
11, 40, 41, 3, 4, 75, 76, 48, 5, 24,
|
554
|
+
25, 6, 50, 7, 8, 9, 10, 1, 2, 11,
|
555
|
+
49, 57, 3, 4, 58, 65, 67, 5, 26, 69,
|
556
|
+
6, 70, 7, 8, 9, 10, 1, 2, 11, 71,
|
557
|
+
72, 3, 4, 79, 27, 0, 5, 0, 0, 6,
|
558
|
+
0, 7, 8, 9, 10, 1, 2, 11, 0, 0,
|
559
|
+
0, 0, 0, 0, 0, 5, 0, 0, 6, 0,
|
560
|
+
7, 8, 9, 10, 0, 0, 11
|
558
561
|
};
|
559
562
|
|
560
|
-
static const
|
563
|
+
static const yysigned_char yycheck[] =
|
561
564
|
{
|
562
|
-
13, 3, 3, 3, 3,
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
565
|
+
13, 3, 3, 3, 3, 10, 10, 22, 23, 3,
|
566
|
+
3, 15, 17, 17, 27, 44, 22, 23, 3, 48,
|
567
|
+
20, 20, 3, 25, 25, 18, 19, 40, 41, 3,
|
568
|
+
4, 0, 6, 7, 8, 9, 17, 18, 19, 13,
|
569
|
+
14, 12, 16, 3, 18, 19, 20, 21, 3, 4,
|
570
|
+
24, 6, 7, 8, 9, 22, 23, 10, 13, 3,
|
571
|
+
4, 16, 20, 18, 19, 20, 21, 3, 4, 24,
|
572
|
+
15, 3, 8, 9, 3, 3, 3, 13, 14, 3,
|
573
|
+
16, 3, 18, 19, 20, 21, 3, 4, 24, 15,
|
574
|
+
20, 8, 9, 3, 5, -1, 13, -1, -1, 16,
|
575
|
+
-1, 18, 19, 20, 21, 3, 4, 24, -1, -1,
|
576
|
+
-1, -1, -1, -1, -1, 13, -1, -1, 16, -1,
|
577
|
+
18, 19, 20, 21, -1, -1, 24
|
572
578
|
};
|
573
579
|
|
574
580
|
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
@@ -577,12 +583,12 @@ static const unsigned char yystos[] =
|
|
577
583
|
{
|
578
584
|
0, 3, 4, 8, 9, 13, 16, 18, 19, 20,
|
579
585
|
21, 24, 27, 28, 29, 30, 31, 32, 33, 34,
|
580
|
-
38, 39, 41, 15, 30, 30, 28, 36, 3,
|
581
|
-
19, 40, 3, 25, 3, 25, 3, 3, 0,
|
582
|
-
7, 29, 12, 10, 17, 3, 14, 10, 15,
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
+
38, 39, 41, 15, 30, 30, 14, 28, 36, 3,
|
587
|
+
18, 19, 40, 3, 25, 3, 25, 3, 3, 0,
|
588
|
+
6, 7, 29, 12, 10, 17, 3, 14, 10, 15,
|
589
|
+
20, 3, 17, 18, 19, 22, 23, 3, 3, 3,
|
590
|
+
20, 3, 20, 29, 29, 3, 31, 3, 31, 3,
|
591
|
+
3, 15, 20, 22, 23, 22, 23, 35, 37, 3
|
586
592
|
};
|
587
593
|
|
588
594
|
#define yyerrok (yyerrstatus = 0)
|
@@ -1303,77 +1309,77 @@ yyreduce:
|
|
1303
1309
|
|
1304
1310
|
case 14:
|
1305
1311
|
#line 118 "src/q_parser.y"
|
1306
|
-
{ (yyval.query) =
|
1312
|
+
{ (yyval.query) = bq_new(true); }
|
1307
1313
|
break;
|
1308
1314
|
|
1309
|
-
case
|
1310
|
-
#line
|
1311
|
-
{
|
1315
|
+
case 15:
|
1316
|
+
#line 119 "src/q_parser.y"
|
1317
|
+
{ (yyval.query) = get_bool_q((yyvsp[-1].bclss)); }
|
1312
1318
|
break;
|
1313
1319
|
|
1314
1320
|
case 20:
|
1315
1321
|
#line 125 "src/q_parser.y"
|
1316
|
-
{ FLDS((yyval.query),
|
1322
|
+
{ FLDS((yyval.query), get_term_q(qp, field, (yyvsp[0].str))); }
|
1317
1323
|
break;
|
1318
1324
|
|
1319
1325
|
case 21:
|
1320
1326
|
#line 126 "src/q_parser.y"
|
1321
|
-
{ FLDS((yyval.query), get_fuzzy_q(qp, field, (yyvsp[-
|
1327
|
+
{ FLDS((yyval.query), get_fuzzy_q(qp, field, (yyvsp[-2].str), (yyvsp[0].str))); }
|
1322
1328
|
break;
|
1323
1329
|
|
1324
1330
|
case 22:
|
1325
|
-
#line
|
1326
|
-
{ FLDS((yyval.query),
|
1331
|
+
#line 127 "src/q_parser.y"
|
1332
|
+
{ FLDS((yyval.query), get_fuzzy_q(qp, field, (yyvsp[-1].str), NULL)); }
|
1327
1333
|
break;
|
1328
1334
|
|
1329
1335
|
case 23:
|
1330
|
-
#line
|
1331
|
-
{ qp
|
1336
|
+
#line 129 "src/q_parser.y"
|
1337
|
+
{ FLDS((yyval.query), get_wild_q(qp, field, (yyvsp[0].str))); }
|
1332
1338
|
break;
|
1333
1339
|
|
1334
1340
|
case 24:
|
1335
1341
|
#line 131 "src/q_parser.y"
|
1336
|
-
{
|
1342
|
+
{ qp->fields = qp->def_fields; }
|
1337
1343
|
break;
|
1338
1344
|
|
1339
1345
|
case 25:
|
1340
1346
|
#line 132 "src/q_parser.y"
|
1341
|
-
{
|
1347
|
+
{ (yyval.query) = (yyvsp[-1].query); }
|
1342
1348
|
break;
|
1343
1349
|
|
1344
1350
|
case 26:
|
1345
|
-
#line
|
1346
|
-
{qp->fields = qp->
|
1351
|
+
#line 133 "src/q_parser.y"
|
1352
|
+
{ qp->fields = qp->all_fields; }
|
1347
1353
|
break;
|
1348
1354
|
|
1349
1355
|
case 27:
|
1350
1356
|
#line 133 "src/q_parser.y"
|
1351
|
-
{
|
1357
|
+
{qp->fields = qp->def_fields;}
|
1352
1358
|
break;
|
1353
1359
|
|
1354
1360
|
case 28:
|
1355
|
-
#line
|
1356
|
-
{ (yyval.
|
1361
|
+
#line 134 "src/q_parser.y"
|
1362
|
+
{ (yyval.query) = (yyvsp[-1].query); }
|
1357
1363
|
break;
|
1358
1364
|
|
1359
1365
|
case 29:
|
1360
1366
|
#line 136 "src/q_parser.y"
|
1361
|
-
{ (yyval.hashset) =
|
1367
|
+
{ (yyval.hashset) = first_field(qp, (yyvsp[0].str)); }
|
1362
1368
|
break;
|
1363
1369
|
|
1364
1370
|
case 30:
|
1365
|
-
#line
|
1366
|
-
{ (yyval.
|
1371
|
+
#line 137 "src/q_parser.y"
|
1372
|
+
{ (yyval.hashset) = add_field(qp, (yyvsp[0].str));}
|
1367
1373
|
break;
|
1368
1374
|
|
1369
1375
|
case 31:
|
1370
1376
|
#line 139 "src/q_parser.y"
|
1371
|
-
{ (yyval.query) = get_phrase_q(qp, (yyvsp[-
|
1377
|
+
{ (yyval.query) = get_phrase_q(qp, (yyvsp[-1].phrase), NULL); }
|
1372
1378
|
break;
|
1373
1379
|
|
1374
1380
|
case 32:
|
1375
1381
|
#line 140 "src/q_parser.y"
|
1376
|
-
{ (yyval.query) =
|
1382
|
+
{ (yyval.query) = get_phrase_q(qp, (yyvsp[-3].phrase), (yyvsp[0].str)); }
|
1377
1383
|
break;
|
1378
1384
|
|
1379
1385
|
case 33:
|
@@ -1382,87 +1388,92 @@ yyreduce:
|
|
1382
1388
|
break;
|
1383
1389
|
|
1384
1390
|
case 34:
|
1385
|
-
#line
|
1386
|
-
{ (yyval.
|
1391
|
+
#line 142 "src/q_parser.y"
|
1392
|
+
{ (yyval.query) = NULL; }
|
1387
1393
|
break;
|
1388
1394
|
|
1389
1395
|
case 35:
|
1390
1396
|
#line 144 "src/q_parser.y"
|
1391
|
-
{ (yyval.phrase) = ph_first_word(
|
1397
|
+
{ (yyval.phrase) = ph_first_word((yyvsp[0].str)); }
|
1392
1398
|
break;
|
1393
1399
|
|
1394
1400
|
case 36:
|
1395
1401
|
#line 145 "src/q_parser.y"
|
1396
|
-
{ (yyval.phrase) =
|
1402
|
+
{ (yyval.phrase) = ph_first_word(NULL); }
|
1397
1403
|
break;
|
1398
1404
|
|
1399
1405
|
case 37:
|
1400
1406
|
#line 146 "src/q_parser.y"
|
1401
|
-
{ (yyval.phrase) = ph_add_word((yyvsp[-
|
1407
|
+
{ (yyval.phrase) = ph_add_word((yyvsp[-1].phrase), (yyvsp[0].str)); }
|
1402
1408
|
break;
|
1403
1409
|
|
1404
1410
|
case 38:
|
1405
1411
|
#line 147 "src/q_parser.y"
|
1406
|
-
{ (yyval.phrase) =
|
1412
|
+
{ (yyval.phrase) = ph_add_word((yyvsp[-2].phrase), NULL); }
|
1407
1413
|
break;
|
1408
1414
|
|
1409
1415
|
case 39:
|
1410
|
-
#line
|
1411
|
-
{
|
1416
|
+
#line 148 "src/q_parser.y"
|
1417
|
+
{ (yyval.phrase) = ph_add_multi_word((yyvsp[-2].phrase), (yyvsp[0].str)); }
|
1412
1418
|
break;
|
1413
1419
|
|
1414
1420
|
case 40:
|
1415
1421
|
#line 150 "src/q_parser.y"
|
1416
|
-
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), true,
|
1422
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), true, true)); }
|
1417
1423
|
break;
|
1418
1424
|
|
1419
1425
|
case 41:
|
1420
1426
|
#line 151 "src/q_parser.y"
|
1421
|
-
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), false
|
1427
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), true, false)); }
|
1422
1428
|
break;
|
1423
1429
|
|
1424
1430
|
case 42:
|
1425
1431
|
#line 152 "src/q_parser.y"
|
1426
|
-
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), false,
|
1432
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), false, true)); }
|
1427
1433
|
break;
|
1428
1434
|
|
1429
1435
|
case 43:
|
1430
1436
|
#line 153 "src/q_parser.y"
|
1431
|
-
{ FLDS((yyval.query), get_r_q(qp, field,
|
1437
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-2].str), (yyvsp[-1].str), false, false)); }
|
1432
1438
|
break;
|
1433
1439
|
|
1434
1440
|
case 44:
|
1435
1441
|
#line 154 "src/q_parser.y"
|
1436
|
-
{ FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[-1].str), false,
|
1442
|
+
{ FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[-1].str), false, false)); }
|
1437
1443
|
break;
|
1438
1444
|
|
1439
1445
|
case 45:
|
1440
1446
|
#line 155 "src/q_parser.y"
|
1441
|
-
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-1].str),
|
1447
|
+
{ FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[-1].str), false, true)); }
|
1442
1448
|
break;
|
1443
1449
|
|
1444
1450
|
case 46:
|
1445
1451
|
#line 156 "src/q_parser.y"
|
1446
|
-
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-1].str), NULL,
|
1452
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-1].str), NULL,true, false)); }
|
1447
1453
|
break;
|
1448
1454
|
|
1449
1455
|
case 47:
|
1450
1456
|
#line 157 "src/q_parser.y"
|
1451
|
-
{ FLDS((yyval.query), get_r_q(qp, field,
|
1457
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[-1].str), NULL,false, false)); }
|
1452
1458
|
break;
|
1453
1459
|
|
1454
1460
|
case 48:
|
1455
1461
|
#line 158 "src/q_parser.y"
|
1456
|
-
{ FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[0].str), false,
|
1462
|
+
{ FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[0].str), false, false)); }
|
1457
1463
|
break;
|
1458
1464
|
|
1459
1465
|
case 49:
|
1460
1466
|
#line 159 "src/q_parser.y"
|
1461
|
-
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[0].str),
|
1467
|
+
{ FLDS((yyval.query), get_r_q(qp, field, NULL,(yyvsp[0].str), false, true)); }
|
1462
1468
|
break;
|
1463
1469
|
|
1464
1470
|
case 50:
|
1465
1471
|
#line 160 "src/q_parser.y"
|
1472
|
+
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[0].str), NULL,true, false)); }
|
1473
|
+
break;
|
1474
|
+
|
1475
|
+
case 51:
|
1476
|
+
#line 161 "src/q_parser.y"
|
1466
1477
|
{ FLDS((yyval.query), get_r_q(qp, field, (yyvsp[0].str), NULL,false, false)); }
|
1467
1478
|
break;
|
1468
1479
|
|
@@ -1471,7 +1482,7 @@ yyreduce:
|
|
1471
1482
|
}
|
1472
1483
|
|
1473
1484
|
/* Line 1126 of yacc.c. */
|
1474
|
-
#line
|
1485
|
+
#line 1486 "y.tab.c"
|
1475
1486
|
|
1476
1487
|
yyvsp -= yylen;
|
1477
1488
|
yyssp -= yylen;
|
@@ -1739,7 +1750,7 @@ yyreturn:
|
|
1739
1750
|
}
|
1740
1751
|
|
1741
1752
|
|
1742
|
-
#line
|
1753
|
+
#line 163 "src/q_parser.y"
|
1743
1754
|
|
1744
1755
|
|
1745
1756
|
const char *special_char = "&:()[]{}!\"~^|<>=*?+-";
|
data/ext/r_index.c
CHANGED
@@ -1233,6 +1233,14 @@ frt_iw_get_doc_count(VALUE self)
|
|
1233
1233
|
return INT2FIX(iw_doc_count(iw));
|
1234
1234
|
}
|
1235
1235
|
|
1236
|
+
static char *
|
1237
|
+
nstrdup(const char *str, int len)
|
1238
|
+
{
|
1239
|
+
char *new = ALLOC_N(char, len + 1);
|
1240
|
+
memcpy(new, str, len + 1);
|
1241
|
+
return new;
|
1242
|
+
}
|
1243
|
+
|
1236
1244
|
static int
|
1237
1245
|
frt_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
|
1238
1246
|
{
|
@@ -1266,17 +1274,25 @@ frt_hash_to_doc_i(VALUE key, VALUE value, VALUE arg)
|
|
1266
1274
|
case T_ARRAY:
|
1267
1275
|
{
|
1268
1276
|
int i;
|
1277
|
+
df->destroy_data = true;
|
1269
1278
|
for (i = 0; i < RARRAY(value)->len; i++) {
|
1270
1279
|
val = rb_obj_as_string(RARRAY(value)->ptr[i]);
|
1271
1280
|
df_add_data_len(df,
|
1272
|
-
RSTRING(val)->ptr,
|
1281
|
+
nstrdup(RSTRING(val)->ptr,
|
1282
|
+
RSTRING(val)->len),
|
1273
1283
|
RSTRING(val)->len);
|
1274
1284
|
}
|
1275
1285
|
}
|
1276
1286
|
break;
|
1287
|
+
case T_STRING:
|
1288
|
+
df_add_data_len(df, RSTRING(value)->ptr, RSTRING(value)->len);
|
1289
|
+
break;
|
1277
1290
|
default:
|
1278
1291
|
val = rb_obj_as_string(value);
|
1279
|
-
|
1292
|
+
df->destroy_data = true;
|
1293
|
+
df_add_data_len(df,
|
1294
|
+
nstrdup(RSTRING(val)->ptr, RSTRING(val)->len),
|
1295
|
+
RSTRING(val)->len);
|
1280
1296
|
break;
|
1281
1297
|
}
|
1282
1298
|
doc_add_field(doc, df);
|
@@ -1303,10 +1319,12 @@ frt_get_doc(VALUE rdoc)
|
|
1303
1319
|
{
|
1304
1320
|
int i;
|
1305
1321
|
df = df_new("content");
|
1322
|
+
df->destroy_data = true;
|
1306
1323
|
for (i = 0; i < RARRAY(rdoc)->len; i++) {
|
1307
1324
|
val = rb_obj_as_string(RARRAY(rdoc)->ptr[i]);
|
1308
1325
|
df_add_data_len(df,
|
1309
|
-
RSTRING(val)->ptr,
|
1326
|
+
nstrdup(RSTRING(val)->ptr,
|
1327
|
+
RSTRING(val)->len),
|
1310
1328
|
RSTRING(val)->len);
|
1311
1329
|
}
|
1312
1330
|
doc_add_field(doc, df);
|
@@ -1317,11 +1335,17 @@ frt_get_doc(VALUE rdoc)
|
|
1317
1335
|
doc_add_field(doc, df);
|
1318
1336
|
break;
|
1319
1337
|
case T_STRING:
|
1338
|
+
df = df_add_data_len(df_new("content"), RSTRING(rdoc)->ptr,
|
1339
|
+
RSTRING(rdoc)->len);
|
1340
|
+
doc_add_field(doc, df);
|
1341
|
+
break;
|
1320
1342
|
default:
|
1321
1343
|
val = rb_obj_as_string(rdoc);
|
1322
1344
|
df = df_add_data_len(df_new("content"),
|
1323
|
-
RSTRING(val)->ptr,
|
1345
|
+
nstrdup(RSTRING(val)->ptr,
|
1346
|
+
RSTRING(val)->len),
|
1324
1347
|
RSTRING(val)->len);
|
1348
|
+
df->destroy_data = true;
|
1325
1349
|
doc_add_field(doc, df);
|
1326
1350
|
break;
|
1327
1351
|
}
|
@@ -2247,7 +2271,7 @@ frt_ir_is_latest(VALUE self)
|
|
2247
2271
|
* index_reader.term_vector(doc_id, field) -> TermVector
|
2248
2272
|
*
|
2249
2273
|
* Return the TermVector for the field +field+ in the document at +doc_id+ in
|
2250
|
-
* the index. See TermVector.
|
2274
|
+
* the index. Return nil of no such term_vector exists. See TermVector.
|
2251
2275
|
*/
|
2252
2276
|
static VALUE
|
2253
2277
|
frt_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
|
@@ -2256,9 +2280,14 @@ frt_ir_term_vector(VALUE self, VALUE rdoc_id, VALUE rfield)
|
|
2256
2280
|
TermVector *tv;
|
2257
2281
|
VALUE rtv;
|
2258
2282
|
tv = ir->term_vector(ir, FIX2INT(rdoc_id), frt_field(rfield));
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2283
|
+
if (tv) {
|
2284
|
+
rtv = frt_get_tv(tv);
|
2285
|
+
tv_destroy(tv);
|
2286
|
+
return rtv;
|
2287
|
+
}
|
2288
|
+
else {
|
2289
|
+
return Qnil;
|
2290
|
+
}
|
2262
2291
|
}
|
2263
2292
|
|
2264
2293
|
static void
|
data/ext/r_store.c
CHANGED
data/lib/ferret/index.rb
CHANGED
@@ -91,7 +91,7 @@ module Ferret::Index
|
|
91
91
|
end
|
92
92
|
|
93
93
|
if (fi = options[:field_infos]).is_a?(String)
|
94
|
-
options[:field_infos] = FieldInfos.load(
|
94
|
+
options[:field_infos] = FieldInfos.load(fi)
|
95
95
|
end
|
96
96
|
|
97
97
|
@close_dir = options[:close_dir]
|
@@ -103,7 +103,8 @@ module Ferret::Index
|
|
103
103
|
begin
|
104
104
|
@dir = FSDirectory.new(options[:path], options[:create])
|
105
105
|
rescue IOError => io
|
106
|
-
@dir = FSDirectory.new(options[:path],
|
106
|
+
@dir = FSDirectory.new(options[:path],
|
107
|
+
options[:create_if_missing] != false)
|
107
108
|
end
|
108
109
|
elsif options[:dir]
|
109
110
|
@dir = options[:dir]
|
@@ -220,7 +221,6 @@ module Ferret::Index
|
|
220
221
|
ensure_writer_open()
|
221
222
|
return @writer
|
222
223
|
end
|
223
|
-
protected :reader, :writer, :searcher
|
224
224
|
|
225
225
|
# Adds a document to this index, using the provided analyzer instead of
|
226
226
|
# the local analyzer if provided. If the document contains more than
|
data/lib/ferret_version.rb
CHANGED
@@ -195,8 +195,8 @@ class QueryParserTest < Test::Unit::TestCase
|
|
195
195
|
|
196
196
|
pairs = [
|
197
197
|
['::*word', 'word'],
|
198
|
-
['
|
199
|
-
['
|
198
|
+
['::*&)(*^&*(', ''],
|
199
|
+
['::*&one)(*two(*&"', '"one two"~1']
|
200
200
|
]
|
201
201
|
|
202
202
|
pairs.each do |query_str, expected|
|
@@ -95,12 +95,12 @@ class NumberToolsTest < Test::Unit::TestCase
|
|
95
95
|
|
96
96
|
def test_date_time_to_s_lex
|
97
97
|
10.times do
|
98
|
-
d1 =
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
d1 = "#{rand(600) + 1600}-#{rand(12)+1}-#{rand(28)+1} " +
|
99
|
+
"#{rand(24)}:#{rand(60)}:#{rand(60)}"
|
100
|
+
d2 = "#{rand(600) + 1600}-#{rand(12)+1}-#{rand(28)+1} " +
|
101
|
+
"#{rand(24)}:#{rand(60)}:#{rand(60)}"
|
102
|
+
d1 = DateTime.strptime(d1, "%Y-%m-%d %H:%M:%S")
|
103
|
+
d2 = DateTime.strptime(d2, "%Y-%m-%d %H:%M:%S")
|
104
104
|
assert_equal(d1.to_s, d1.to_s_lex(:second).to_date_time_lex.to_s)
|
105
105
|
assert_equal(d2.to_s, d2.to_s_lex(:second).to_date_time_lex.to_s)
|
106
106
|
[:year, :month, :day, :hour, :minute, :second].each do |prec|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ferret
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.10.
|
7
|
-
date: 2006-09-
|
6
|
+
version: 0.10.9
|
7
|
+
date: 2006-09-27 00:00:00 +09:00
|
8
8
|
summary: Ruby indexing library.
|
9
9
|
require_paths:
|
10
10
|
- lib
|