Skip to content

Instantly share code, notes, and snippets.

@6
Created March 5, 2016 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 6/48b551bc663b7f9cb87d to your computer and use it in GitHub Desktop.
Save 6/48b551bc663b7f9cb87d to your computer and use it in GitHub Desktop.
LireSolr tweaked for searching very similar images
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
25 0
26 0
27 0
28 0
29 0
30 0
31 0
32 0
33 0
34 0
35 0
36 0
37 0
38 0
39 0
40 0
41 0
42 0
43 0
44 0
45 0
46 0
47 0
48 0
49 0
50 0
51 0
52 0
53 0
54 0
55 0
56 0
57 0
58 0
59 0
60 0
61 0
62 0
63 0
64 0
65 0
66 0
67 0
68 0
69 0
70 0
71 0
72 0
73 0
74 0
75 0
76 0
77 0
78 0
79 0
80 0
81 0
82 0
83 0
84 0
85 0
86 0
87 0
88 0
89 0
90 0
91 0
92 0
93 0
94 0
95 0
96 0
97 0
98 0
99 0
100 0
101 0
102 0
103 0
104 0
105 0
106 0
107 0
108 0
109 0
110 0
111 0
112 0
113 0
114 0
115 0
116 0
117 0
118 0
119 0
120 0
121 0
122 0
123 0
124 0
125 0
126 0
127 0
128 0
129 0
130 0
131 0
132 0
133 0
134 0
135 0
136 0
137 0
138 0
139 0
140 0
141 0
142 0
143 0
144 0
145 0
146 0
147 0
148 0
149 0
150 0
151 0
152 0
153 0
154 0
155 0
156 0
157 0
158 0
159 0
160 0
161 0
162 0
163 0
164 0
165 0
166 0
167 0
168 0
169 0
170 0
171 0
172 0
173 0
174 0
175 0
176 0
177 0
178 0
179 0
180 0
181 0
182 0
183 0
184 0
185 0
186 0
187 0
188 0
189 0
190 0
191 0
192 0
193 0
194 0
195 0
196 0
197 0
198 0
199 0
200 0
201 0
202 0
203 0
204 0
205 0
206 0
207 0
208 0
209 0
210 0
211 0
212 0
213 0
214 0
215 0
216 0
217 0
218 0
219 0
220 0
221 0
222 0
223 0
224 0
225 0
226 0
227 0
228 0
229 0
230 0
231 0
232 0
233 0
234 0
235 0
236 0
237 0
238 0
239 0
240 0
241 0
242 0
243 0
244 0
245 0
246 0
247 0
248 0
249 0
250 0
251 0
252 0
253 0
254 0
255 0
256 178662
257 41878
258 14956
259 15579
260 126083
261 1118607
262 601627
263 13584325
264 2496257
265 55414
266 130846
267 41089
268 47907
269 47636
270 11239
271 235830
272 5346222
273 250973
274 322920
275 369372
276 2688362
277 2135856
278 4405951
279 63776199
280 90337
281 30433
282 16429
283 212328
284 303761
285 28074971
286 216487
287 76515753
288 330862
289 53617
290 153577
291 12306
292 16114427
293 63284
294 66269146
295 496267
296 47410
297 668877
298 3408527
299 24509311
300 49475
301 485024
302 302405
303 2884166
304 10985513
305 524053
306 4998951
307 258169
308 18205972
309 748174
310 277061458
311 4831691
312 1057305
313 13537849
314 40104440
315 75150418
316 8884
317 3046480
318 46284
319 6871532
320 1203732
321 124694
322 412302
323 885610
324 4841
325 11886338
326 188785
327 28722490
328 2869369
329 309006
330 4290802
331 933769
332 189558
333 133291
334 1070599
335 840318
336 7304719
337 440038
338 508387
339 17589554
340 7842
341 10049885
342 986049
343 109031454
344 1096426
345 5958508
346 7736090
347 31708634
348 621682
349 293183
350 31241171
351 20679004
352 50027
353 342623
354 112330
355 5042
356 74146
357 4926
358 817537
359 119018
360 62654
361 272952
362 2207038
363 22002
364 7031
365 211321
366 334
367 1911
368 19785
369 719162
370 78270
371 735832
372 78206
373 3512
374 1537107
375 586742
376 38346
377 180589
378 172192
379 171370
380 30899
381 19267
382 5053
383 3731
384 2063
385 633
386 619730
387 4217458
388 135
389 166807
390 25092
391 1225815
392 14985
393 4776
394 20115959
395 16053371
396 569
397 13795
398 3953
399 358612
400 733
401 1511402
402 437431
403 7433643
404 3958
405 8525777
406 100001
407 7754209
408 11252
409 1063400
410 5127253
411 32365945
412 47001
413 3600970
414 30913
415 3200761
416 32409
417 14269
418 435381
419 70303
420 3687
421 4861
422 7714
423 33130
424 433852
425 333804
426 15773200
427 20857477
428 1175
429 179378
430 529
431 4137070
432 20347
433 47729
434 206910
435 573692
436 11486
437 1656
438 30371
439 70744
440 2750308
441 26921940
442 12554113
443 114322457
444 42315
445 16999550
446 18613
447 35730697
448 26875
449 40094
450 11057
451 101554
452 3082
453 6304106
454 44602
455 5956697
456 69360
457 54255
458 108500
459 32223
460 27331
461 60442
462 1956236
463 1206912
464 86238
465 592663
466 69494
467 8888102
468 4144
469 3940451
470 125339
471 6170813
472 4428
473 455210
474 269477
475 1576595
476 1058180
477 1335774
478 8724539
479 3499603
480 302478
481 90815
482 1367990
483 174314
484 71
485 751
486 5722
487 22720
488 2205138
489 155577
490 36158718
491 1384780
492 516
493 289161
494 390
495 991539
496 89643
497 1091965
498 534661
499 4168952
500 408
501 760
502 13713
503 53443
504 97515
505 73630
506 699617
507 643590
508 9232398
509 365295
510 11332714
511 754763
512 546403
513 3593441
514 324974
515 35078
516 13508952
517 91644248
518 82752
519 149043
520 210
521 92765
522 588
523 890
524 1382
525 25943
526 283
527 20703
528 67019
529 12811
530 3629
531 156198
532 9284489
533 360219
534 23816
535 302290
536 14181
537 74987075
538 43
539 6408226
540 6077943
541 1896839
542 835
543 110439
544 838393
545 13561092
546 61453
547 194235
548 2609773
549 31230870
550 899957
551 322536
552 33840
553 800481
554 527640
555 4319825
556 3158911
557 2217326
558 5463600
559 62875276
560 59181
561 39719
562 6639
563 38640
564 16314
565 39770
566 63324
567 20415
568 381209
569 1938700
570 63755
571 407541
572 628430
573 4262750
574 276721
575 1440520
576 4733693
577 43671568
578 33454
579 305752
580 3011434
581 90324483
582 36982
583 120554
584 16279
585 1258087
586 7030
587 104839
588 10667
589 794042
590 26153
591 29922
592 5462033
593 77811
594 32559
595 4216786
596 885176
597 1054207
598 75998
599 72983
600 203627
601 119813250
602 42703
603 138580682
604 1212200
605 13704111
606 1212261
607 2459521
608 121961
609 40886473
610 19466
611 720961
612 179321
613 19380389
614 1123235
615 35571
616 3546015
617 6664589
618 4201
619 4812
620 25244
621 10215057
622 54
623 21748
624 12758
625 66423598
626 11086
627 7124346
628 36334
629 36292
630 350061
631 740
632 47796540
633 13188427
634 30684
635 338903
636 1183762
637 54860150
638 92
639 92599
640 299
641 117912
642 44890
643 82240
644 34369
645 95870
646 179
647 68856
648 2354
649 2632364
650 300
651 623623
652 873
653 1636
654 1522
655 6081795
656 0
657 4388325
658 171711
659 15888103
660 1602
661 1325584
662 324562
663 16211227
664 1400
665 1293315
666 3095943
667 4180050
668 264
669 4623487
670 176739178
671 172973213
672 802
673 321732
674 18885
675 666750
676 1876
677 193952
678 2399
679 117213
680 50520
681 23747272
682 809772
683 12939442
684 5626165
685 2286668
686 2863455
687 6298726
688 297
689 368679
690 186
691 1959242
692 41
693 1874
694 38
695 7063
696 202760
697 8060733
698 169715
699 7660780
700 106770
701 3514435
702 71788
703 181398
704 23327
705 11848879
706 679
707 77838525
708 38870
709 84056089
710 100
711 38537421
712 28521922
713 5458307
714 4009
715 2876
716 37380797
717 5475518
718 95471
719 1436231
720 37552
721 4358146
722 6087
723 17746898
724 2916
725 77539095
726 13942
727 3309023
728 91519961
729 53401394
730 75220
731 546364
732 20685546
733 108341438
734 1006402
735 3949479
736 148
737 8072842
738 1073
739 37889812
740 32
741 3231906
742 99
743 40699034
744 179
745 23651
746 1953
747 216289
748 2655
749 1190054
750 358
751 19474061
752 154
753 40456617
754 4766
755 30447642
756 11
757 520820
758 0
759 163340
760 528
761 6212
762 275
763 11034
764 2057
765 38408234
766 2933
767 3110425
768 63728
769 11440
770 30118
771 4204
772 39113
773 301214
774 215545
775 4955810
776 1059074
777 21027
778 2498978
779 9222
780 2831
781 14087
782 185750
783 176510
784 3032813
785 87767
786 70367
787 41370
788 432090
789 189970
790 809383
791 7681329
792 127294
793 8513795
794 421298
795 286107
796 72182
797 13257
798 17972
799 171797
800 62625
801 15652
802 166462
803 1284
804 13518473
805 68673
806 34297354
807 216596
808 452
809 1219
810 18460
811 2432
812 49950
813 131337969
814 210436
815 1814984
816 3798692
817 172072
818 787480
819 9811
820 6520058
821 88349
822 28543094
823 1108920
824 3677872
825 1191
826 33036359
827 2411
828 56456
829 33803462
830 115190
831 1308798
832 1630402
833 7289
834 339636
835 337768
836 2978
837 1159305
838 50730
839 3976981
840 9574878
841 99112
842 87349303
843 334202
844 16573
845 16792
846 222446
847 72682
848 741309
849 5945
850 666087
851 2765134
852 2570
853 385443
854 255205
855 4022532
856 931738
857 2736169
858 14422045
859 4254988
860 308936
861 152144
862 14941363
863 1503768
864 9553
865 300578
866 33813
867 223927
868 99478
869 23625
870 770542
871 42421
872 2614662
873 40638
874 35938
875 1015
876 29107
877 75385821
878 255
879 2157516
880 8433
881 9520005
882 81305
883 1423695
884 44832
885 12846
886 412167
887 63050
888 49534655
889 520083
890 186412
891 3888
892 423317
893 42170208
894 3721
895 1899274
896 3442
897 133630
898 636953
899 203469
900 43
901 33585
902 12398
903 1946511
904 149272
905 3267726
906 55287007
907 3263437
908 3689
909 3631
910 162631
911 75512126
912 699
913 10887408
914 33508
915 105750782
916 338
917 22516622
918 19908
919 106459467
920 58679
921 1887242
922 1782757
923 971577
924 1685
925 1948696
926 3515
927 3238043
928 1056
929 96342
930 29052
931 215883
932 66930
933 97398
934 3431
935 12564
936 2074
937 44974435
938 71136
939 9296731
940 2975769
941 103351789
942 482
943 9268
944 15868
945 67608
946 80783
947 1168974
948 9329
949 7862
950 10337
951 17236
952 15734037
953 8598085
954 52357131
955 9695194
956 97521
957 578169
958 64181
959 2682
960 16113
961 165032
962 10594
963 588326
964 1072
965 4140261
966 44838
967 29257756
968 10513324
969 3344095
970 2258973
971 6888
972 27180872
973 7253585
974 855546
975 192681231
976 6044
977 2814905
978 2031570
979 105146719
980 737
981 14439442
982 34937
983 12495268
984 20975122
985 12786998
986 1044731
987 415707
988 14358420
989 7891702
990 2640760
991 25833218
992 15655
993 1712909
994 106423
995 1391640
996 296096
997 184164
998 860
999 19775
1000 4808
1001 18494
1002 103909
1003 147012
1004 78801945
1005 172888231
1006 173
1007 467142
1008 17059
1009 4398803
1010 1044793
1011 46569251
1012 10959
1013 15745
1014 1826
1015 12569
1016 37411
1017 3224
1018 126532
1019 22927
1020 227997
1021 3143418
1022 3718
1023 186311
1024 1462977
1025 760396
1026 44743353
1027 77068
1028 37168
1029 275883
1030 5310387
1031 1264680
1032 15231
1033 202448
1034 78303
1035 84760
1036 83188
1037 113936
1038 3193634
1039 1190371
1040 18914
1041 70156
1042 280
1043 19140
1044 29169
1045 79318
1046 84604
1047 1666952
1048 2465
1049 6978
1050 6815
1051 5581
1052 11522
1053 6702619
1054 859689
1055 1391283
1056 5247
1057 288428
1058 2509
1059 873579
1060 3068
1061 959188
1062 124713
1063 7016939
1064 282944
1065 3019581
1066 9715
1067 42661444
1068 1580426
1069 5340191
1070 1684119
1071 33905140
1072 5522
1073 17809
1074 1580
1075 96366
1076 2294
1077 738
1078 142450
1079 32808
1080 31643
1081 8159
1082 3105905
1083 1139741
1084 28743
1085 16538
1086 2714728
1087 211650
1088 5683
1089 2479755
1090 14564
1091 52451
1092 3040
1093 2121277
1094 38486
1095 37154
1096 236531
1097 2651600
1098 372528
1099 9236137
1100 46679
1101 67587
1102 251648
1103 677278
1104 114203
1105 867972
1106 297630
1107 4885007
1108 2427
1109 587158
1110 66779
1111 38840551
1112 2242462
1113 14624688
1114 1101548
1115 18283929
1116 111995
1117 38574
1118 3215702
1119 2602182
1120 2322
1121 357323
1122 122
1123 754099
1124 919
1125 1317268
1126 88902
1127 9065127
1128 5557
1129 2867589
1130 419
1131 30182087
1132 123941
1133 4162159
1134 94102
1135 32573107
1136 338
1137 110379
1138 234
1139 545840
1140 1280
1141 1067
1142 293154
1143 23301
1144 1694
1145 6145
1146 1006
1147 57588
1148 26614
1149 3561
1150 712787
1151 15838
1152 2007248
1153 331784
1154 21117323
1155 273088
1156 213678
1157 679108
1158 28023762
1159 35569782
1160 870
1161 3329
1162 72659
1163 198201
1164 357775
1165 640490
1166 69796793
1167 12361870
1168 874
1169 1931
1170 406
1171 2518
1172 8340
1173 10981
1174 13081515
1175 78335609
1176 2189293
1177 1146
1178 2231
1179 5710
1180 13001
1181 5012
1182 17044308
1183 1551633
1184 7113
1185 25563
1186 1950
1187 255796
1188 99574
1189 70380
1190 31015992
1191 83989015
1192 66089
1193 117250
1194 3369
1195 17635479
1196 3488321
1197 1743618
1198 40297829
1199 36518371
1200 1058
1201 1800
1202 189
1203 4325
1204 59895
1205 8354
1206 21943891
1207 9665955
1208 8819864
1209 3532
1210 89842
1211 89775
1212 129732
1213 40779
1214 42796203
1215 2478723
1216 45
1217 930470
1218 6420
1219 1295
1220 707
1221 8669788
1222 4487773
1223 5509787
1224 68757
1225 1986971
1226 97718
1227 6866366
1228 4574
1229 3477
1230 1872752
1231 2273650
1232 560
1233 25967
1234 9503
1235 387087
1236 257
1237 383738
1238 4400862
1239 106143630
1240 112297
1241 2147141
1242 75141
1243 2082580
1244 11384
1245 9256
1246 4410380
1247 3233042
1248 571
1249 10543
1250 1419
1251 192485
1252 2876
1253 28731
1254 3702883
1255 5277140
1256 44
1257 11025
1258 277
1259 29442781
1260 375
1261 27796
1262 236598
1263 31065885
1264 10994644
1265 96440231
1266 902195
1267 34400665
1268 874974
1269 16320442
1270 21840250
1271 17131134
1272 1021677
1273 8159243
1274 261591
1275 4629563
1276 92905
1277 1340520
1278 3087050
1279 1359330
1280 31686034
1281 1384438
1282 8458831
1283 212753
1284 253050
1285 779077
1286 12603935
1287 11173915
1288 2083853
1289 636741
1290 1666131
1291 388594
1292 89692
1293 315521
1294 9464952
1295 14194866
1296 48096407
1297 2532164
1298 2284573
1299 143071
1300 3097866
1301 655225
1302 2552120
1303 3672288
1304 25011
1305 3282
1306 47406
1307 89905
1308 33692
1309 40790498
1310 131521
1311 181909381
1312 39602420
1313 9687055
1314 16760
1315 58515
1316 648304
1317 6896950
1318 10687
1319 2515206
1320 1426063
1321 12861279
1322 547230
1323 2911233
1324 2498847
1325 4894846
1326 28285
1327 3877211
1328 128427019
1329 5064344
1330 1288474
1331 76647
1332 8195472
1333 1431692
1334 2279290
1335 221887
1336 116511
1337 279762
1338 1249046
1339 3511299
1340 2172
1341 14866
1342 144663
1343 50840
1344 204984081
1345 238562
1346 102289999
1347 135150
1348 1454449
1349 5655238
1350 968569
1351 3531623
1352 21112253
1353 295413
1354 7806901
1355 211742
1356 359166
1357 4757842
1358 4102938
1359 29210511
1360 158576
1361 180210
1362 420348
1363 1854718
1364 5427
1365 297623
1366 52425
1367 216894
1368 1765873
1369 3956318
1370 2964815
1371 6271235
1372 569071
1373 215925
1374 27929106
1375 79885192
1376 5427
1377 488661
1378 431
1379 91444
1380 13752
1381 21663265
1382 41838
1383 13005844
1384 29358
1385 1049188
1386 520
1387 627050
1388 372191
1389 5226685
1390 223746
1391 11533314
1392 1079
1393 251791
1394 174
1395 6548
1396 5038
1397 1231655
1398 26602
1399 239652
1400 1056
1401 135160
1402 1330
1403 3413
1404 36031
1405 33521
1406 60793
1407 73968
1408 25480
1409 185582
1410 1393606
1411 5024509
1412 567
1413 9136
1414 1298676
1415 13713571
1416 13633
1417 302413
1418 140404830
1419 30085064
1420 89
1421 247
1422 1392647
1423 26600704
1424 18211
1425 2198858
1426 22311
1427 6691488
1428 7228
1429 778240
1430 24792
1431 7185832
1432 51451
1433 2623
1434 2163726
1435 1515982
1436 131782
1437 3010
1438 65322
1439 8676
1440 1080569
1441 58004466
1442 315
1443 200906
1444 1171
1445 415
1446 162190
1447 223693
1448 354586
1449 58029493
1450 514278
1451 688086
1452 114
1453 5352
1454 527757
1455 673268
1456 44019
1457 2092226
1458 5700
1459 14932679
1460 13110
1461 98143
1462 3248
1463 985412
1464 1355317
1465 152066
1466 2807132
1467 1830638
1468 350749
1469 21398
1470 279787
1471 149879
1472 10629
1473 154476
1474 9749
1475 24159
1476 128
1477 569681
1478 11454
1479 25473
1480 102659
1481 44052
1482 76487
1483 108204
1484 75384
1485 19261
1486 5609003
1487 17269837
1488 5538
1489 120628
1490 28702
1491 287329
1492 822
1493 65252
1494 30331
1495 1474512
1496 11937
1497 27893
1498 178940
1499 60872
1500 646702
1501 16233
1502 11809676
1503 21563193
1504 7350
1505 175905
1506 122
1507 3244
1508 8233
1509 82754
1510 30007
1511 48069
1512 197
1513 38199
1514 11
1515 39698
1516 10924
1517 2029
1518 706
1519 325657
1520 19306
1521 994263
1522 1571
1523 130815
1524 341
1525 22891
1526 2867
1527 4508
1528 387
1529 4547
1530 128
1531 2846
1532 26104933
1533 22
1534 45259365
1535 2662
1536 12346847
1537 50450606
1538 81480878
1539 5899
1540 4593790
1541 3943608
1542 6832
1543 12390
1544 321068
1545 129023
1546 984
1547 2603
1548 111265
1549 25517
1550 3233
1551 10486
1552 58739022
1553 87126444
1554 391
1555 3729
1556 4932010
1557 1836566
1558 1024
1559 79996
1560 3907956
1561 830579
1562 1176706
1563 1578241
1564 911749
1565 68579
1566 924
1567 44
1568 21598860
1569 52688329
1570 7187
1571 277405
1572 114681
1573 823813
1574 66322
1575 2313938
1576 147449
1577 400072
1578 114888
1579 3014113
1580 7348294
1581 2357189
1582 14686035
1583 71900681
1584 44973560
1585 78824712
1586 92629
1587 756103
1588 236257
1589 571827
1590 60019
1591 860877
1592 5583473
1593 43622101
1594 123906812
1595 112098305
1596 2352425
1597 909085
1598 5999710
1599 17332311
1600 534097
1601 935798
1602 2980
1603 6261
1604 916680
1605 516200
1606 61
1607 179
1608 46016
1609 55875
1610 850
1611 6298
1612 87540
1613 35766
1614 27456
1615 21078
1616 197067
1617 128290
1618 9991
1619 125734
1620 317633
1621 94892
1622 16487
1623 79458
1624 210284
1625 488990
1626 7634
1627 275661
1628 197382
1629 79159682
1630 600605
1631 158443
1632 18057772
1633 60770681
1634 26381
1635 1022
1636 343587
1637 1207631
1638 1420628
1639 587
1640 13727577
1641 603900
1642 123447
1643 19072
1644 20032
1645 240428
1646 657
1647 4801
1648 25734582
1649 19403441
1650 34175
1651 24753
1652 129178
1653 53210
1654 1465658
1655 2739
1656 30827766
1657 14016446
1658 140316
1659 60064
1660 330821
1661 265035033
1662 4231
1663 1774657
1664 106383
1665 949489
1666 39397667
1667 107160
1668 11311
1669 46357
1670 8384
1671 36631
1672 452
1673 562777
1674 460757
1675 44182969
1676 269
1677 390
1678 16279
1679 21489
1680 43604
1681 161196
1682 1761
1683 76269
1684 11850
1685 169608
1686 11893
1687 87530428
1688 2691
1689 70059
1690 339454
1691 8934695
1692 1247
1693 35081
1694 632092
1695 89255
1696 115494
1697 1543342
1698 2605
1699 274470
1700 8307
1701 213449
1702 104926
1703 1227928
1704 205413
1705 5854063
1706 26217
1707 2236305
1708 18948269
1709 4604417
1710 11133627
1711 16620663
1712 242601
1713 1307376
1714 4092
1715 178160
1716 3899
1717 30739
1718 14775
1719 406175
1720 197643
1721 4347374
1722 136584
1723 2307880
1724 2564470
1725 660551
1726 3689471
1727 4725301
1728 44973
1729 94709
1730 368
1731 2359
1732 7687
1733 114314
1734 154
1735 13220
1736 112
1737 34
1738 324
1739 258
1740 1296
1741 139
1742 95029
1743 20625
1744 16309
1745 26095
1746 1202
1747 55756
1748 1760
1749 2597256
1750 5282
1751 7924720
1752 391
1753 718
1754 826
1755 2115
1756 9297
1757 2173146
1758 411853
1759 5737076
1760 1437899
1761 10851659
1762 96
1763 11353
1764 140266
1765 1075540
1766 1216
1767 168333
1768 22
1769 1217
1770 57
1771 4662
1772 59
1773 1032
1774 10
1775 8919
1776 10491145
1777 30866184
1778 1392288
1779 11868665
1780 4295063
1781 25058908
1782 1001943
1783 25114714
1784 2118505
1785 16670008
1786 1020304
1787 11951174
1788 890491
1789 11296040
1790 671991
1791 23237869
1792 1506686
1793 990494
1794 64265
1795 243297
1796 908
1797 2934122
1798 92421
1799 1992210
1800 616438
1801 14715
1802 864348
1803 88883
1804 2605
1805 220684
1806 86614
1807 991568
1808 16522153
1809 813588
1810 202406
1811 89272
1812 99683
1813 2136298
1814 54848
1815 310580
1816 353094
1817 802
1818 452317
1819 7467
1820 15577
1821 20573
1822 17866
1823 10930
1824 3006306
1825 722009
1826 135
1827 10349
1828 2162
1829 3187123
1830 2997
1831 1203139
1832 60465
1833 766768
1834 1834
1835 6370
1836 8848
1837 107954
1838 2492
1839 169112
1840 32803541
1841 1128471
1842 88284
1843 2920794
1844 230693
1845 1634487
1846 137561
1847 3226900
1848 374670
1849 3005
1850 1722284
1851 52603
1852 223691
1853 5518
1854 1721908
1855 46867
1856 1056772
1857 5576414
1858 1259833
1859 9633281
1860 12338
1861 28681299
1862 22911
1863 32740206
1864 17585905
1865 912529
1866 61245392
1867 12471885
1868 100456
1869 12751409
1870 1134510
1871 116043200
1872 445006
1873 906347
1874 751577
1875 485718
1876 20942
1877 7502691
1878 80516
1879 2304894
1880 11972000
1881 29256
1882 46170977
1883 499389
1884 278832
1885 300723
1886 4893542
1887 2356691
1888 3821
1889 73011
1890 4285
1891 30240
1892 5620
1893 12300819
1894 393495
1895 7068077
1896 894891
1897 44014
1898 945
1899 1422
1900 12748
1901 668789
1902 33689
1903 2312622
1904 1685
1905 13982
1906 14042
1907 3137
1908 10390
1909 3320838
1910 743909
1911 755849
1912 2153037
1913 105073
1914 3301
1915 203
1916 11642
1917 35836
1918 2839
1919 37492
1920 3316
1921 126625
1922 1129518
1923 3017285
1924 15
1925 3690
1926 73922
1927 2104401
1928 293541
1929 679311
1930 76441361
1931 139531926
1932 23460115
1933 591
1934 78635
1935 2877541
1936 174511
1937 7517588
1938 316261
1939 14223407
1940 42101
1941 22289130
1942 316837
1943 49886773
1944 100694
1945 87453
1946 6296899
1947 157355893
1948 4656
1949 642857
1950 8305
1951 100827
1952 219733
1953 3122451
1954 106
1955 243722
1956 17
1957 1637
1958 997
1959 39220
1960 115515
1961 10020071
1962 102736
1963 1634546
1964 3910939
1965 4806
1966 8323
1967 20391
1968 390279
1969 14046374
1970 437262
1971 89828489
1972 40081
1973 11041418
1974 383449
1975 60263760
1976 5958871
1977 2555825
1978 11629104
1979 1740688
1980 12588
1981 4938
1982 76136
1983 10023
1984 9058
1985 180
1986 7055
1987 11548
1988 136
1989 13373
1990 1211
1991 10580
1992 26131940
1993 7896
1994 1795462
1995 31179
1996 260235426
1997 3087
1998 205000
1999 73760
2000 19252
2001 64437
2002 43002
2003 589589
2004 4607
2005 21704328
2006 15919
2007 5998324
2008 664382
2009 467
2010 2319767
2011 2816
2012 47169
2013 9712098
2014 700253
2015 7217304
2016 900
2017 2354
2018 151
2019 254
2020 1453
2021 1419
2022 72834
2023 1478
2024 1936129
2025 4604
2026 3
2027 36
2028 42697217
2029 2927
2030 716
2031 2
2032 15648
2033 25221
2034 19494
2035 424922
2036 1522
2037 12642900
2038 2401
2039 13969339
2040 4
2041 59
2042 8
2043 278
2044 4575
2045 3048184
2046 751
2047 11139229
2048 13080757
2049 239117
2050 16087909
2051 1701533
2052 13168011
2053 68735
2054 631350
2055 492747
2056 2456845
2057 877531
2058 38196137
2059 6628745
2060 26985463
2061 283510
2062 1213443
2063 1059288
2064 3927786
2065 37809
2066 1163537
2067 3310823
2068 15861001
2069 22360
2070 1304224
2071 7524398
2072 4703320
2073 1988548
2074 2518240
2075 3306044
2076 82846645
2077 991737
2078 2578718
2079 1324408
2080 167053773
2081 57871
2082 25312542
2083 1326712
2084 40748272
2085 41406
2086 23475659
2087 1253467
2088 2461121
2089 269007
2090 75456873
2091 9355353
2092 714065
2093 208338
2094 7616484
2095 4110099
2096 47375989
2097 498226
2098 2681306
2099 63167235
2100 5570990
2101 3221
2102 2826320
2103 1502889
2104 1051083
2105 81426
2106 1164247
2107 9178221
2108 33863
2109 9358
2110 39608
2111 35019
2112 6181771
2113 58688
2114 2423253
2115 1603853
2116 11309817
2117 68325
2118 153823
2119 244319
2120 884263
2121 166021
2122 2584539
2123 2189299
2124 124652627
2125 5489427
2126 1431269
2127 1586276
2128 157136904
2129 7945430
2130 190228
2131 14769649
2132 3918640
2133 2024240
2134 75626
2135 6256867
2136 4328887
2137 1773929
2138 668472
2139 3689937
2140 66844471
2141 3154460
2142 2205402
2143 1933136
2144 212942
2145 516527
2146 1821316
2147 3827077
2148 8593118
2149 62583
2150 11283599
2151 494444
2152 351881
2153 171865
2154 17705134
2155 25010431
2156 6552567
2157 1298145
2158 513627
2159 267143
2160 180342
2161 61818024
2162 197356
2163 105313322
2164 570948
2165 111889
2166 1006458
2167 296856
2168 97694
2169 6451082
2170 14209990
2171 47575984
2172 1473802
2173 427223
2174 274686
2175 95807
2176 2936832
2177 417829
2178 28191849
2179 3359881
2180 2279
2181 11470
2182 15613
2183 2152788
2184 196142
2185 134465
2186 17963527
2187 15888144
2188 81525
2189 127326
2190 334309
2191 1705905
2192 66659
2193 1047357
2194 5351561
2195 82418004
2196 224
2197 592543
2198 7054
2199 170526895
2200 2840503
2201 346060
2202 52449714
2203 35739687
2204 2133
2205 392088
2206 15075
2207 83172496
2208 88256
2209 7831
2210 2143996
2211 225760
2212 33843
2213 58774
2214 160564
2215 280814
2216 2651823
2217 42884
2218 110260261
2219 2490791
2220 131118
2221 87100
2222 2370056
2223 2148860
2224 5302
2225 103496
2226 26186
2227 4554146
2228 4450
2229 3063
2230 3648
2231 53778
2232 33394618
2233 10156
2234 387141
2235 325251
2236 15747
2237 3517
2238 9719
2239 37086
2240 54274
2241 1691
2242 56485
2243 92254
2244 579
2245 2316
2246 24194
2247 48315
2248 25827
2249 25193
2250 608512
2251 535473
2252 59586
2253 95661
2254 63795
2255 186967
2256 2128932
2257 97385
2258 3406350
2259 7977119
2260 1592
2261 17835
2262 5670
2263 3025269
2264 4132
2265 56022
2266 131750
2267 327292
2268 86509
2269 8142868
2270 422522
2271 1752532
2272 121476
2273 1267576
2274 389363
2275 1677461
2276 6923
2277 1412592
2278 40043
2279 106048112
2280 1355258
2281 8701
2282 9125159
2283 4521086
2284 6958
2285 474396
2286 59853
2287 41489927
2288 6358
2289 71513173
2290 238077
2291 37705541
2292 288
2293 40088
2294 1419
2295 17732
2296 16378
2297 80031
2298 14049445
2299 48067288
2300 3462
2301 126046
2302 81822
2303 87635
2304 536120
2305 5523
2306 7328714
2307 175552
2308 1695924
2309 345729
2310 186856
2311 4564166
2312 50423436
2313 1280334
2314 15877896
2315 452269
2316 33145980
2317 53421
2318 356305
2319 26422444
2320 128970
2321 2101
2322 180714
2323 574642
2324 408436
2325 86778
2326 387547
2327 2585515
2328 33217673
2329 175685498
2330 13676466
2331 3525760
2332 31038691
2333 548774
2334 25290127
2335 3016997
2336 844210
2337 213
2338 13983674
2339 578331
2340 14497124
2341 12565
2342 129584436
2343 5829531
2344 799824
2345 16196
2346 72500853
2347 856147
2348 205310
2349 113939
2350 1649990
2351 34086722
2352 2214360
2353 207660
2354 313122
2355 23131347
2356 385443
2357 595
2358 192152
2359 475180
2360 5662032
2361 6342063
2362 29291590
2363 7371495
2364 863983
2365 47033
2366 74787
2367 2458
2368 1571974
2369 9355
2370 1496151
2371 359316
2372 316708
2373 917366
2374 103875
2375 2063987
2376 71576212
2377 645385
2378 2664822
2379 314570
2380 57791387
2381 1459221
2382 885727
2383 323389
2384 400835
2385 1519486
2386 150801
2387 2187506
2388 213616
2389 2294205
2390 178739
2391 2593880
2392 16679249
2393 132999098
2394 6912485
2395 4811673
2396 50380476
2397 2008350
2398 7792166
2399 2253912
2400 2298342
2401 11886302
2402 469248
2403 18612375
2404 694537
2405 86969
2406 380898
2407 818447
2408 7032811
2409 185496549
2410 5216845
2411 56537452
2412 4892086
2413 1018577
2414 115349
2415 39395
2416 96217
2417 3133413
2418 62664
2419 74935207
2420 52279
2421 32003
2422 75862
2423 176181
2424 170217
2425 13669558
2426 3300100
2427 86316989
2428 4410034
2429 502390
2430 79949
2431 15955
2432 2504451
2433 762362
2434 11495341
2435 3230667
2436 23669
2437 240311
2438 31867
2439 1283234
2440 377556
2441 3109035
2442 3201402
2443 12205956
2444 138187
2445 6417
2446 23800
2447 840348
2448 82962
2449 201825
2450 3254659
2451 2965907
2452 208
2453 337500
2454 36721
2455 995564
2456 587911
2457 107832
2458 18890564
2459 81205508
2460 402153
2461 69753
2462 158652
2463 4855509
2464 48842
2465 14556
2466 642905
2467 1303933
2468 4544
2469 1204
2470 33749
2471 135187
2472 1386459
2473 1812000
2474 88170456
2475 1406593
2476 290
2477 246
2478 13155
2479 11032
2480 25524
2481 241362
2482 258910
2483 28024556
2484 9133
2485 354
2486 12869
2487 423969
2488 16988177
2489 225392
2490 5502809
2491 4219221
2492 234202
2493 3162
2494 45577
2495 5351
2496 21402
2497 2086
2498 15702
2499 73660
2500 5717
2501 2367002
2502 23650
2503 2368226
2504 980904
2505 2382
2506 170558
2507 72369
2508 1789169
2509 33784
2510 55646
2511 38366
2512 13640
2513 19166
2514 5879466
2515 17134489
2516 5445
2517 165307
2518 23953
2519 689309
2520 766855
2521 30032
2522 187028
2523 790139
2524 28267566
2525 111374
2526 24096114
2527 249900
2528 365841
2529 197256
2530 1970217
2531 957455
2532 13924
2533 5568
2534 68366
2535 108693
2536 6532111
2537 152492
2538 200237910
2539 1754332
2540 2345
2541 8874
2542 2398
2543 5597
2544 182013
2545 879335
2546 1633070
2547 109741677
2548 896
2549 18630
2550 6122
2551 186746
2552 488809
2553 101294
2554 8463193
2555 25883009
2556 36375824
2557 9766
2558 47655640
2559 12747
2560 5679289
2561 303555
2562 8379496
2563 3377887
2564 2106647
2565 172638
2566 1317974
2567 1995914
2568 3212490
2569 4933037
2570 8088925
2571 23543361
2572 6547574
2573 1874373
2574 1291471
2575 6652420
2576 1324755
2577 94320
2578 642539
2579 732867
2580 78609893
2581 98140
2582 3444933
2583 34386980
2584 2119198
2585 5956808
2586 5045281
2587 6596213
2588 45410010
2589 2388107
2590 2770656
2591 1936806
2592 26990237
2593 63433
2594 20469328
2595 652177
2596 7594631
2597 46607
2598 60284290
2599 4690008
2600 516066
2601 482604
2602 6315776
2603 9956663
2604 346408
2605 498687
2606 5236362
2607 6145369
2608 5157645
2609 452770
2610 2264658
2611 1224032
2612 1014870
2613 3621
2614 2662935
2615 105450
2616 2048067
2617 3164784
2618 184003
2619 93672
2620 1942494
2621 3299550
2622 71512
2623 43252
2624 3202541
2625 336130
2626 1275832
2627 12224549
2628 802448
2629 477353
2630 187715
2631 2060607
2632 714989
2633 4509689
2634 2918030
2635 57417023
2636 13459650
2637 1621540
2638 272296
2639 22736925
2640 7734777
2641 10853225
2642 89364
2643 35036731
2644 10499728
2645 18193969
2646 23513
2647 81717927
2648 1222321
2649 16116185
2650 5441257
2651 67910303
2652 16591549
2653 6353743
2654 471413
2655 3738449
2656 842276
2657 50370512
2658 384084
2659 1746145
2660 33621847
2661 44379
2662 42615561
2663 359617
2664 505119
2665 2198877
2666 786775
2667 101816120
2668 281672
2669 3266752
2670 355713
2671 43076747
2672 154368
2673 271407756
2674 32976
2675 27534773
2676 3135247
2677 847696
2678 3507573
2679 856497
2680 45967082
2681 32448539
2682 8747
2683 274191
2684 11088338
2685 72445036
2686 6246
2687 293098
2688 1152983
2689 406371
2690 16905672
2691 668808
2692 6477
2693 291592
2694 9024
2695 122120
2696 524413
2697 3380640
2698 1755964
2699 10035563
2700 200814
2701 1604894
2702 403077
2703 7690361
2704 10776
2705 7093728
2706 2388356
2707 37981118
2708 669
2709 1307365
2710 20511
2711 2303721
2712 11494
2713 750603
2714 2087
2715 317188
2716 14419
2717 1418968
2718 2550
2719 231539
2720 2497
2721 89593
2722 29878
2723 194391
2724 4455882
2725 101358366
2726 46569
2727 360518
2728 41087
2729 4649570
2730 1557132
2731 4870972
2732 8537810
2733 18650900
2734 1874970
2735 6515279
2736 621
2737 107217
2738 5310
2739 2051875
2740 184449
2741 2234913
2742 12895
2743 98031
2744 852085
2745 799275
2746 141482
2747 621233
2748 888327
2749 2458219
2750 259168
2751 940805
2752 12941
2753 34214
2754 12071
2755 296447
2756 474
2757 68817310
2758 1917
2759 1164107
2760 65579
2761 882038
2762 368158
2763 6412608
2764 23575
2765 8782984
2766 42246
2767 3085950
2768 24312
2769 85587
2770 15242510
2771 25868079
2772 127
2773 34020
2774 94
2775 20084
2776 4244
2777 67393
2778 7241
2779 388180
2780 47699
2781 20201738
2782 6601
2783 966031
2784 22853
2785 5767813
2786 11170
2787 1982481
2788 77511
2789 3516485
2790 5532
2791 7350171
2792 7542
2793 27100
2794 137481
2795 540919
2796 84334
2797 1266961
2798 91339
2799 902816
2800 3214
2801 117284654
2802 110152
2803 31719706
2804 6163
2805 2179232
2806 1504
2807 55419
2808 207
2809 2132
2810 1078
2811 25612
2812 11540
2813 2231077
2814 19218
2815 286452
2816 58915994
2817 1984
2818 1348956
2819 289324
2820 7305454
2821 580626
2822 3693335
2823 16591823
2824 145297903
2825 890476
2826 1799146
2827 2291674
2828 84731142
2829 127771
2830 37599290
2831 134211786
2832 24091
2833 18623
2834 970693
2835 475254
2836 493975
2837 149151
2838 2096589
2839 4540684
2840 54888138
2841 7444288
2842 28132399
2843 6224288
2844 26111529
2845 2242170
2846 31112925
2847 3783278
2848 22765
2849 220
2850 33793109
2851 869881
2852 8483261
2853 2819
2854 120396170
2855 15279541
2856 70818
2857 848
2858 7208544
2859 2950114
2860 121677
2861 7490865
2862 24053592
2863 84526546
2864 59422
2865 6544
2866 107556
2867 170076
2868 32107
2869 356
2870 321936
2871 452498
2872 9558240
2873 5088
2874 15941325
2875 36472
2876 736866
2877 3218995
2878 114340
2879 234427
2880 1227312
2881 2952
2882 1077973
2883 289079
2884 19921
2885 2056589
2886 102715
2887 3081493
2888 4186490
2889 106954
2890 8582599
2891 2371058
2892 5638503
2893 371517
2894 130875
2895 471693
2896 184909
2897 6638695
2898 1860476
2899 4916069
2900 83489
2901 75339731
2902 830226
2903 43750274
2904 4063419
2905 1272227
2906 27741441
2907 31241358
2908 18904492
2909 1753142
2910 6696603
2911 3798002
2912 514831
2913 2219875
2914 24981
2915 40600
2916 6530
2917 15508
2918 1102985
2919 35354
2920 777847
2921 834644
2922 22915
2923 226862
2924 129066
2925 29096940
2926 68299
2927 1807911
2928 60671
2929 16521275
2930 20082
2931 857259
2932 2074
2933 235743
2934 113383
2935 53852
2936 154373856
2937 618095
2938 15657
2939 27716
2940 1768837
2941 15265451
2942 1205
2943 894572
2944 23130919
2945 5408451
2946 40673108
2947 10935677
2948 405083
2949 331964
2950 62999
2951 1808441
2952 42341851
2953 22235671
2954 2611303
2955 3504189
2956 6625796
2957 12002
2958 329022
2959 3157655
2960 136289
2961 2298429
2962 11928185
2963 39292109
2964 267
2965 1244941
2966 135321
2967 4186861
2968 520634
2969 1901978
2970 359307
2971 1509570
2972 890228
2973 154351
2974 225558
2975 872802
2976 49045
2977 223841
2978 122847
2979 279297
2980 124909
2981 298236
2982 27801
2983 40974
2984 128391
2985 129676196
2986 35097
2987 7052009
2988 159772
2989 62140
2990 24504
2991 23073
2992 16348
2993 46574
2994 74731
2995 1759672
2996 9932
2997 2595
2998 9860
2999 32848
3000 15853138
3001 7543119
3002 11480891
3003 5108781
3004 284833
3005 21157
3006 64688
3007 1768
3008 839937
3009 7689
3010 6726
3011 58481
3012 12576
3013 51442840
3014 37564
3015 9523543
3016 1402085
3017 5162
3018 68715
3019 87966
3020 270705
3021 6114462
3022 5003
3023 10527867
3024 4131
3025 72028
3026 13024875
3027 90354037
3028 3585
3029 146404
3030 88375
3031 355817
3032 269885
3033 64626
3034 269793
3035 82612
3036 2637968
3037 257642
3038 100803
3039 8055186
3040 46181
3041 467184
3042 55686
3043 45255
3044 558
3045 338356
3046 4255
3047 21301
3048 12296
3049 49097
3050 78281
3051 3893
3052 1445
3053 1696326
3054 396
3055 12319
3056 20494
3057 15987018
3058 483304
3059 18332300
3060 643
3061 790617
3062 1544
3063 15644
3064 17752
3065 2759
3066 57542
3067 32131
3068 26916
3069 551029
3070 828
3071 14831
3072 1855091
3073 30194105
3074 26848447
3075 2850264
3076 211499
3077 49831840
3078 34031936
3079 5041751
3080 879461
3081 586614
3082 3377695
3083 1661282
3084 26426343
3085 1832474
3086 18204992
3087 4785140
3088 200926
3089 1015480
3090 2651438
3091 5852036
3092 141147
3093 1681461
3094 7781943
3095 56547051
3096 731312
3097 1664881
3098 724582
3099 643111
3100 2028924
3101 1485293
3102 4075710
3103 753507
3104 165850
3105 283025
3106 1332809
3107 1089087
3108 3406116
3109 2360756
3110 15510757
3111 3130976
3112 5060143
3113 2826545
3114 60035
3115 9171303
3116 68971584
3117 8123429
3118 1223778
3119 3040033
3120 168609
3121 3788016
3122 1281617
3123 46639635
3124 1561528
3125 1237656
3126 61343910
3127 215483158
3128 1682257
3129 21231
3130 610421
3131 2196766
3132 437973
3133 227435
3134 313539
3135 33439
3136 2370
3137 25768833
3138 2204
3139 48316
3140 140223
3141 110693418
3142 178127
3143 91723
3144 136000
3145 192972
3146 45372
3147 68184
3148 21099177
3149 6006602
3150 10118178
3151 3045207
3152 198
3153 1554115
3154 1157
3155 2640562
3156 70282
3157 10058994
3158 263287
3159 1036018
3160 38086
3161 252173
3162 245150
3163 237911
3164 6703553
3165 1284873
3166 20869327
3167 4023863
3168 88595
3169 4730685
3170 43609
3171 2675130
3172 5597127
3173 3010101
3174 6289846
3175 10312139
3176 5273198
3177 65125490
3178 10050061
3179 93738926
3180 54689594
3181 10656510
3182 5572321
3183 9275802
3184 9210
3185 98754390
3186 9783
3187 42236820
3188 1144425
3189 216283
3190 1743981
3191 678883
3192 85200
3193 429111
3194 1433730
3195 9685211
3196 4330264
3197 330441
3198 2820609
3199 391016
3200 23232006
3201 5309308
3202 95648940
3203 10028197
3204 178
3205 2597512
3206 2534965
3207 2458878
3208 228
3209 1111
3210 4310854
3211 11146472
3212 710
3213 16975
3214 1684086
3215 2628235
3216 2992796
3217 17005
3218 2117212
3219 201543
3220 66176850
3221 52953
3222 956206
3223 6954791
3224 59276985
3225 2754
3226 3719
3227 78989
3228 88370
3229 50498
3230 44042
3231 10159892
3232 29439
3233 15127
3234 235230
3235 224148
3236 12097
3237 43767
3238 96302583
3239 107616589
3240 350
3241 29243
3242 9341
3243 3462222
3244 24935
3245 8956
3246 8536041
3247 3622294
3248 2514
3249 5801
3250 172524
3251 4011564
3252 2982
3253 3571
3254 2651384
3255 10723705
3256 202596483
3257 31290
3258 542046
3259 3245016
3260 303300
3261 1405
3262 200412
3263 208071
3264 65
3265 3048222
3266 16704543
3267 668358
3268 14
3269 108437370
3270 63413549
3271 314704
3272 1
3273 208
3274 7973470
3275 78467
3276 5173
3277 56351
3278 28369712
3279 64046
3280 9
3281 39867
3282 19892647
3283 60759153
3284 375
3285 2781361
3286 8744
3287 1259377
3288 112927
3289 176
3290 27893
3291 388443
3292 22992
3293 57276
3294 619138
3295 684069
3296 126278
3297 615877
3298 59775253
3299 7821984
3300 441785
3301 547227
3302 117556400
3303 6052783
3304 26349998
3305 91903446
3306 24684007
3307 32446371
3308 360
3309 12824
3310 35149122
3311 6020620
3312 1028500
3313 5971885
3314 486722
3315 12562248
3316 61660
3317 198272
3318 53296
3319 238158
3320 1702684
3321 1925794
3322 786295
3323 7648933
3324 9796
3325 8855
3326 13319
3327 35600
3328 161028
3329 508584
3330 5251824
3331 2094020
3332 40936
3333 66666
3334 9619425
3335 5974535
3336 945101
3337 766009
3338 1019535
3339 1325247
3340 7666992
3341 1775277
3342 10461246
3343 10582340
3344 13084
3345 15205
3346 545072
3347 380594
3348 48778
3349 13374
3350 1571450
3351 4056373
3352 332536
3353 2498814
3354 523411
3355 137208
3356 2709133
3357 174271
3358 10701284
3359 501657
3360 96697
3361 8140459
3362 693917
3363 930165
3364 9711096
3365 22233035
3366 6309677
3367 50088736
3368 19044427
3369 51642360
3370 1231238
3371 2950773
3372 70585786
3373 62953475
3374 5681151
3375 115656111
3376 29141
3377 110155
3378 245614
3379 61335355
3380 8154862
3381 20589767
3382 13351936
3383 42171750
3384 3833189
3385 7873317
3386 4876541
3387 21631920
3388 3800240
3389 5010143
3390 3223203
3391 9235333
3392 2704857
3393 358998
3394 733909
3395 11391
3396 406728
3397 331598
3398 276372
3399 43576
3400 3418077
3401 519929
3402 12967087
3403 232564
3404 17874364
3405 2039905
3406 7595061
3407 1207592
3408 125589
3409 60465
3410 56429
3411 621842
3412 324417
3413 106356
3414 434573
3415 361683
3416 354927
3417 7408105
3418 1712744
3419 1237830
3420 22992315
3421 557095
3422 46148829
3423 6046449
3424 187476
3425 8112123
3426 68649
3427 1012045
3428 5941867
3429 21147847
3430 10414024
3431 248678773
3432 68653194
3433 112311574
3434 276389374
3435 66897664
3436 54232967
3437 19006514
3438 3484546
3439 1853502
3440 5262
3441 16376114
3442 11538
3443 56696507
3444 404735
3445 1058018
3446 518264
3447 6916600
3448 102011
3449 15858064
3450 1715738
3451 11268545
3452 10670318
3453 243598
3454 3389246
3455 334633
3456 6382152
3457 4213548
3458 12891009
3459 15877294
3460 231
3461 61662
3462 2031549
3463 7331546
3464 2127
3465 1585116
3466 8134392
3467 31453568
3468 11213
3469 32739
3470 2283412
3471 13706012
3472 776376
3473 1805020
3474 879356
3475 7400362
3476 3701634
3477 651996
3478 308850
3479 1589213
3480 1198268
3481 622
3482 459136
3483 3251
3484 1317417
3485 10332
3486 389677
3487 4760
3488 69248
3489 19220017
3490 46673
3491 989408
3492 45810
3493 21990
3494 77620
3495 81136
3496 9380
3497 137532837
3498 90652
3499 966158
3500 77437
3501 298463
3502 89538
3503 114684
3504 12621
3505 465189
3506 23780
3507 118765446
3508 270822
3509 51911
3510 476566
3511 2166071
3512 28039738
3513 21281
3514 3832233
3515 62609146
3516 3609332
3517 174913
3518 1898763
3519 234620
3520 3298
3521 385082
3522 25345
3523 533111
3524 186
3525 1410284
3526 12590
3527 32372
3528 28329
3529 12798
3530 391718
3531 312019
3532 6497
3533 7996
3534 96917
3535 125519
3536 6829
3537 346727
3538 5575582
3539 16859982
3540 1836
3541 152290
3542 10860
3543 176885
3544 7275
3545 655
3546 39917
3547 310988
3548 7982229
3549 31042
3550 6647122
3551 373397
3552 215769
3553 2088832
3554 201029
3555 487752
3556 19360947
3557 13185171
3558 11229280
3559 13907234
3560 15952391
3561 47167419
3562 11789313
3563 26903642
3564 811
3565 2283
3566 2179
3567 19577
3568 7879
3569 7390625
3570 275319
3571 35639627
3572 134477
3573 209346
3574 193723
3575 793894
3576 329404
3577 528878
3578 1333245
3579 14186360
3580 51951513
3581 1178
3582 60498898
3583 17216
3584 766607
3585 220465879
3586 94383289
3587 13674660
3588 63381
3589 297537
3590 2582345
3591 1572439
3592 37943
3593 279645
3594 327072
3595 287065
3596 1495769
3597 588496
3598 276552
3599 1396726
3600 69724
3601 1191520
3602 45266497
3603 12800558
3604 87064
3605 76996
3606 95084722
3607 191717653
3608 1211983
3609 2954493
3610 7411618
3611 6030270
3612 857700
3613 685110
3614 516590
3615 339279
3616 16894141
3617 12069446
3618 2584870
3619 40864
3620 1426209
3621 266107
3622 80963373
3623 10233623
3624 52592
3625 154466
3626 212974
3627 1629328
3628 1131345
3629 761592
3630 2194902
3631 5061774
3632 3485674
3633 3458575
3634 2739551
3635 445425
3636 628742
3637 13140
3638 255608816
3639 121394804
3640 8902651
3641 10252404
3642 32067790
3643 17124178
3644 5153547
3645 1891171
3646 41843005
3647 417305
3648 725663
3649 1393547
3650 355
3651 20689
3652 20590
3653 6387376
3654 1239
3655 195436
3656 1324
3657 76998
3658 9002
3659 2671386
3660 337621
3661 3367327
3662 105866
3663 29002869
3664 11533
3665 162746
3666 781
3667 2227445
3668 353
3669 326241
3670 976
3671 20146953
3672 73741
3673 1162036
3674 54071
3675 1148673
3676 51474
3677 522258
3678 125586
3679 13244257
3680 18427523
3681 70328093
3682 519962
3683 173924
3684 52952821
3685 3467258
3686 126895953
3687 39024
3688 619036
3689 1753813
3690 212607
3691 15273033
3692 253556
3693 1544699
3694 2449545
3695 82079619
3696 3762775
3697 81934593
3698 220590
3699 4463222
3700 13627501
3701 11581
3702 28662914
3703 2684999
3704 25319717
3705 28306540
3706 19916
3707 357865
3708 25753848
3709 39718969
3710 195675
3711 3234433
3712 3445705
3713 1272267
3714 90427805
3715 1756607
3716 1872
3717 573138
3718 9746
3719 34974
3720 1023
3721 106784
3722 11034
3723 313293
3724 1366
3725 271094
3726 4962
3727 19110
3728 7822646
3729 68359139
3730 2004293
3731 50248915
3732 103216253
3733 1210605
3734 12957288
3735 12325080
3736 133620
3737 17637002
3738 1192204
3739 132091978
3740 238023
3741 1013441
3742 35283
3743 5133422
3744 109342
3745 337996
3746 301239
3747 39259
3748 100674
3749 141742281
3750 3552523
3751 1042484
3752 37
3753 159644
3754 13497
3755 35023
3756 280546
3757 30156868
3758 121584
3759 2908786
3760 120843
3761 9270378
3762 554709
3763 3636772
3764 15192
3765 4939796
3766 14892302
3767 20783643
3768 4530920
3769 10908583
3770 2855472
3771 35779957
3772 241901
3773 4924768
3774 2467669
3775 2763385
3776 35431
3777 102183
3778 570
3779 95017
3780 2294
3781 43885695
3782 66
3783 529487
3784 0
3785 10
3786 1257
3787 118607
3788 86
3789 7608982
3790 320
3791 119218
3792 3081
3793 1403100
3794 79946435
3795 72561727
3796 2397
3797 829455
3798 1733
3799 2767179
3800 1120
3801 462898
3802 202915
3803 6140118
3804 59053
3805 7647429
3806 288045
3807 55188671
3808 1114381
3809 8125420
3810 5577
3811 46629
3812 4679080
3813 19482031
3814 67709652
3815 275522
3816 496281
3817 2614584
3818 69137
3819 169549
3820 473173
3821 7254329
3822 3259865
3823 1238761
3824 622248
3825 2322862
3826 168893
3827 1053931
3828 123576
3829 1493673
3830 438383
3831 6661077
3832 24145
3833 254474
3834 184289
3835 909496
3836 45808
3837 3160440
3838 311810
3839 66632075
3840 178276
3841 121674832
3842 104554109
3843 41253649
3844 40749
3845 12229
3846 2581780
3847 1729582
3848 400645
3849 205734
3850 908661
3851 202116
3852 1341407
3853 115207
3854 456991
3855 278219
3856 48329
3857 314472
3858 12703911
3859 6684183
3860 150391
3861 112928
3862 501604
3863 5278625
3864 2269340
3865 29516
3866 958644
3867 100462
3868 4039839
3869 27111
3870 1766391
3871 134708
3872 170829
3873 2068496
3874 15011060
3875 4182207
3876 2711
3877 4281
3878 68895357
3879 7549568
3880 101735
3881 2786590
3882 554559
3883 135864
3884 701348
3885 550536
3886 11271254
3887 1083029
3888 26375
3889 102721
3890 3998106
3891 2023059
3892 900957
3893 38888
3894 6730158
3895 356890
3896 14334490
3897 16930
3898 17251693
3899 66115
3900 41608586
3901 718434
3902 114975148
3903 1551659
3904 2490276
3905 9925
3906 2435491
3907 606
3908 43
3909 21613472
3910 4990
3911 1569263
3912 8383630
3913 3715
3914 15690526
3915 64857
3916 126495
3917 4337783
3918 37176
3919 1668840
3920 808933
3921 60351
3922 623549
3923 240390
3924 346
3925 1609657
3926 5774
3927 8431176
3928 7856249
3929 10552
3930 13632967
3931 171540
3932 47148
3933 8694
3934 894178
3935 2419225
3936 23789
3937 3239063
3938 34120
3939 80288
3940 441473
3941 2275613
3942 51793279
3943 132652
3944 136498
3945 430035
3946 698916
3947 578204
3948 156501
3949 580156
3950 837725
3951 7405865
3952 5369
3953 8614093
3954 22956
3955 843145
3956 3186
3957 1682
3958 1311464
3959 3640
3960 742827
3961 21570
3962 8250
3963 52214
3964 2232
3965 1215
3966 71067
3967 1239423
3968 10486863
3969 9698966
3970 28598202
3971 12223427
3972 1416
3973 26478
3974 14966
3975 382266
3976 49506
3977 460543
3978 9210449
3979 5348731
3980 89935
3981 6696
3982 18471
3983 421775
3984 20296390
3985 1303830
3986 8753564
3987 5378045
3988 81006884
3989 1698095
3990 39902543
3991 7011243
3992 5275045
3993 57201
3994 1310257
3995 53887
3996 19896483
3997 259920
3998 4470947
3999 79085
4000 43644
4001 996039
4002 1106468
4003 610448
4004 3792
4005 36300
4006 5350
4007 22144
4008 6106
4009 5206645
4010 39951
4011 259780
4012 5020
4013 9394
4014 2554
4015 1020
4016 67879
4017 891157
4018 222126
4019 10926521
4020 1392730
4021 379614
4022 7162227
4023 3482129
4024 28261623
4025 265266
4026 10312364
4027 258808
4028 54091658
4029 1170085
4030 40117469
4031 1890429
4032 4747
4033 910
4034 3697
4035 21025
4036 388
4037 88246615
4038 503
4039 6405590
4040 19073
4041 281
4042 41707
4043 35124
4044 250
4045 10369407
4046 2387
4047 671830
4048 16217
4049 111271
4050 9539262
4051 11264866
4052 4680
4053 3492921
4054 20722
4055 1863752
4056 48888
4057 962
4058 50004
4059 13461
4060 81489
4061 14994346
4062 195381
4063 23614903
4064 66016
4065 862980
4066 24411
4067 70391
4068 11166306
4069 2548974
4070 189401345
4071 40153
4072 878273
4073 2239301
4074 236441
4075 369751
4076 691026
4077 609710
4078 3900000
4079 3543
4080 7161
4081 2873062
4082 34692
4083 910898
4084 7924
4085 4790497
4086 9944
4087 11825289
4088 1971
4089 9484
4090 4477
4091 26288
4092 67616
4093 7604831
4094 38700
4095 44493809
/*
* This file is part of the LIRE project: http://www.semanticmetadata.net/lire
* LIRE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LIRE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LIRE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* We kindly ask you to refer the any or one of the following publications in
* any publication mentioning or employing Lire:
*
* Lux Mathias, Savvas A. Chatzichristofis. Lire: Lucene Image Retrieval –
* An Extensible Java CBIR Library. In proceedings of the 16th ACM International
* Conference on Multimedia, pp. 1085-1088, Vancouver, Canada, 2008
* URL: http://doi.acm.org/10.1145/1459359.1459577
*
* Lux Mathias. Content Based Image Retrieval with LIRE. In proceedings of the
* 19th ACM International Conference on Multimedia, pp. 735-738, Scottsdale,
* Arizona, USA, 2011
* URL: http://dl.acm.org/citation.cfm?id=2072432
*
* Mathias Lux, Oge Marques. Visual Information Retrieval using Java and LIRE
* Morgan & Claypool, 2013
* URL: http://www.morganclaypool.com/doi/abs/10.2200/S00468ED1V01Y201301ICR025
*
* Copyright statement:
* --------------------
* (c) 2002-2013 by Mathias Lux (mathias@juggle.at)
* http://www.semanticmetadata.net/lire, http://www.lire-project.net
*/
package net.semanticmetadata.lire.solr;
import net.semanticmetadata.lire.imageanalysis.EdgeHistogram;
import net.semanticmetadata.lire.imageanalysis.LireFeature;
import net.semanticmetadata.lire.impl.SimpleResult;
import net.semanticmetadata.lire.indexing.hashing.BitSampling;
import net.semanticmetadata.lire.utils.ImageUtils;
import org.apache.commons.codec.binary.Base64;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.*;
import org.apache.lucene.queries.TermsFilter;
import org.apache.lucene.search.*;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.handler.RequestHandlerBase;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.search.SolrIndexSearcher;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.*;
import java.io.*;
/**
* This is the main LIRE RequestHandler for the Solr Plugin. It supports query by example using the indexed id,
* an url or a feature vector. Furthermore, feature extraction and random selection of images are supported.
*
* @author Mathias Lux, mathias@juggle.at, 07.07.13
*/
public class LireRequestHandler extends RequestHandlerBase {
private HashMap<Integer,Integer> docCount = new HashMap<Integer, Integer>();
// private static HashMap<String, Class> fieldToClass = new HashMap<String, Class>(5);
private long time = 0;
private int countRequests = 0;
private int defaultNumberOfResults = 60;
/**
* number of candidate results retrieved from the index. The higher this number, the slower,
* the but more accurate the retrieval will be. 10k is a good value for starters.
*/
private int numberOfCandidateResults = 10000;
private static final int DEFAULT_NUMBER_OF_CANDIDATES = 10000;
/**
* The number of query terms that go along with the TermsFilter search. We need some to get a
* score, the less the faster. I put down a minimum of three in the method, this value gives
* the percentage of the overall number used (selected randomly).
*/
private double numberOfQueryTerms = 0.33;
private static final double DEFAULT_NUMBER_OF_QUERY_TERMS = 0.33;
static {
// one time hash function read ...
try {
BitSampling.readHashFunctions();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void init(NamedList args) {
super.init(args);
try{
BufferedReader br = new BufferedReader(new FileReader("/var/solr/data/anime_cl/histogram.csv"));
String line = null;
while((line=br.readLine())!=null){
String str[] = line.split(",");
docCount.put(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
}
} catch(Exception e){
}
}
/**
* Handles three types of requests.
* <ol>
* <li>search by already extracted images.</li>
* <li>search by an image URL.</li>
* <li>Random results.</li>
* </ol>
*
* @param req
* @param rsp
* @throws Exception
*/
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
// (1) check if the necessary parameters are here
if (req.getParams().get("hashes") != null) { // we are searching for hashes ...
handleHashSearch(req, rsp);
} else if (req.getParams().get("url") != null) { // we are searching for an image based on an URL
handleUrlSearch(req, rsp);
} else if (req.getParams().get("id") != null) { // we are searching for an image based on an URL
handleIdSearch(req, rsp);
} else if (req.getParams().get("extract") != null) { // we are trying to extract from an image URL.
handleExtract(req, rsp);
} else { // lets return random results.
handleRandomSearch(req, rsp);
}
}
/**
* Handles the get parameters id, field and rows.
*
* @param req
* @param rsp
* @throws IOException
* @throws InstantiationException
* @throws IllegalAccessException
*/
private void handleIdSearch(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException, InstantiationException, IllegalAccessException {
SolrIndexSearcher searcher = req.getSearcher();
try {
TopDocs hits = searcher.search(new TermQuery(new Term("id", req.getParams().get("id"))), 1);
String paramField = "cl_ha";
if (req.getParams().get("field") != null)
paramField = req.getParams().get("field");
LireFeature queryFeature = (LireFeature) FeatureRegistry.getClassForHashField(paramField).newInstance();
rsp.add("QueryField", paramField);
rsp.add("QueryFeature", queryFeature.getClass().getName());
numberOfQueryTerms = req.getParams().getDouble("accuracy", DEFAULT_NUMBER_OF_QUERY_TERMS);
numberOfCandidateResults = req.getParams().getInt("candidates", DEFAULT_NUMBER_OF_CANDIDATES);
if (hits.scoreDocs.length > 0) {
// Using DocValues to get the actual data from the index.
BinaryDocValues binaryValues = MultiDocValues.getBinaryValues(searcher.getIndexReader(), FeatureRegistry.getFeatureFieldName(paramField)); // *** #
if (binaryValues == null)
System.err.println("Could not find the DocValues of the query document. Are they in the index?");
BytesRef bytesRef = new BytesRef();
bytesRef = binaryValues.get(hits.scoreDocs[0].doc);
// Document d = searcher.getIndexReader().document(hits.scoreDocs[0].doc);
// String histogramFieldName = paramField.replace("_ha", "_hi");
queryFeature.setByteArrayRepresentation(bytesRef.bytes, bytesRef.offset, bytesRef.length);
int paramRows = defaultNumberOfResults;
if (req.getParams().getInt("rows") != null)
paramRows = req.getParams().getInt("rows");
// Re-generating the hashes to save space (instead of storing them in the index)
int[] hashes = BitSampling.generateHashes(queryFeature.getDoubleHistogram());
List<Term> termFilter = createTermFilter(hashes, paramField);
doSearch(req, rsp, searcher, paramField, paramRows, termFilter, createQuery(hashes, paramField, numberOfQueryTerms), queryFeature);
} else {
rsp.add("Error", "Did not find an image with the given id " + req.getParams().get("id"));
}
} catch (Exception e) {
rsp.add("Error", "There was an error with your search for the image with the id " + req.getParams().get("id")
+ ": " + e.getMessage());
}
}
/**
* Returns a random set of documents from the index. Mainly for testing purposes.
*
* @param req
* @param rsp
* @throws IOException
*/
private void handleRandomSearch(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException {
SolrIndexSearcher searcher = req.getSearcher();
DirectoryReader indexReader = searcher.getIndexReader();
double maxDoc = indexReader.maxDoc();
int paramRows = defaultNumberOfResults;
if (req.getParams().getInt("rows") != null)
paramRows = req.getParams().getInt("rows");
LinkedList list = new LinkedList();
while (list.size() < paramRows) {
HashMap m = new HashMap(2);
Document d = indexReader.document((int) Math.floor(Math.random() * maxDoc));
m.put("id", d.getValues("id")[0]);
m.put("title", d.getValues("title")[0]);
list.add(m);
}
rsp.add("docs", list);
}
/**
* Searches for an image given by an URL. Note that (i) extracting image features takes time and
* (ii) not every image is readable by Java.
*
* @param req
* @param rsp
* @throws IOException
* @throws InstantiationException
* @throws IllegalAccessException
*/
private void handleUrlSearch(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException, InstantiationException, IllegalAccessException {
SolrParams params = req.getParams();
String paramUrl = params.get("url");
String paramField = "cl_ha";
if (req.getParams().get("field") != null)
paramField = req.getParams().get("field");
int paramRows = defaultNumberOfResults;
if (params.get("rows") != null)
paramRows = params.getInt("rows");
numberOfQueryTerms = req.getParams().getDouble("accuracy", DEFAULT_NUMBER_OF_QUERY_TERMS);
numberOfCandidateResults = req.getParams().getInt("candidates", DEFAULT_NUMBER_OF_CANDIDATES);
LireFeature feat = null;
List<Term> termFilter = null;
int[] hashes = null;
// wrapping the whole part in the try
try {
BufferedImage img = ImageIO.read(new URL(paramUrl).openStream());
img = ImageUtils.trimWhiteSpace(img);
// getting the right feature per field:
if (paramField == null || FeatureRegistry.getClassForHashField(paramField) == null) // if the feature is not registered.
feat = new EdgeHistogram();
else {
feat = (LireFeature) FeatureRegistry.getClassForHashField(paramField).newInstance();
}
feat.extract(img);
hashes = BitSampling.generateHashes(feat.getDoubleHistogram());
termFilter = createTermFilter(hashes, paramField);
ArrayList<String> hashStrings = new ArrayList<String>(hashes.length);
for (int i = 0; i < hashes.length; i++) {
hashStrings.add(Integer.toHexString(hashes[i]));
}
rsp.add("hashes", hashStrings);
} catch (Exception e) {
rsp.add("Error", "Error reading image from URL: " + paramUrl + ": " + e.getMessage());
e.printStackTrace();
}
// search if the feature has been extracted.
if (feat != null)
doSearch(req, rsp, req.getSearcher(), paramField, paramRows, termFilter, createQuery(hashes, paramField, numberOfQueryTerms), feat);
}
private void handleExtract(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException, InstantiationException, IllegalAccessException {
SolrParams params = req.getParams();
String paramUrl = params.get("extract");
String paramField = "cl_ha";
if (req.getParams().get("field") != null)
paramField = req.getParams().get("field");
// int paramRows = defaultNumberOfResults;
// if (params.get("rows") != null)
// paramRows = params.getInt("rows");
LireFeature feat = null;
// BooleanQuery query = null;
// wrapping the whole part in the try
try {
BufferedImage img = ImageIO.read(new URL(paramUrl).openStream());
img = ImageUtils.trimWhiteSpace(img);
// getting the right feature per field:
if (paramField == null || FeatureRegistry.getClassForHashField(paramField) == null) // if the feature is not registered.
feat = new EdgeHistogram();
else {
feat = (LireFeature) FeatureRegistry.getClassForHashField(paramField).newInstance();
}
feat.extract(img);
rsp.add("histogram", Base64.encodeBase64String(feat.getByteArrayRepresentation()));
int[] hashes = BitSampling.generateHashes(feat.getDoubleHistogram());
ArrayList<String> hashStrings = new ArrayList<String>(hashes.length);
for (int i = 0; i < hashes.length; i++) {
hashStrings.add(Integer.toHexString(hashes[i]));
}
//Collections.shuffle(hashStrings);
rsp.add("hashes", hashStrings);
// just use 50% of the hashes for search ...
// query = createTermFilter(hashes, paramField, 0.5d);
} catch (Exception e) {
// rsp.add("Error", "Error reading image from URL: " + paramUrl + ": " + e.getMessage());
e.printStackTrace();
}
// search if the feature has been extracted.
// if (feat != null) doSearch(rsp, req.getSearcher(), paramField, paramRows, query, feat);
}
/**
* Search based on the given image hashes.
*
* @param req
* @param rsp
* @throws IOException
* @throws IllegalAccessException
* @throws InstantiationException
*/
private void handleHashSearch(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException, IllegalAccessException, InstantiationException {
SolrParams params = req.getParams();
SolrIndexSearcher searcher = req.getSearcher();
// get the params needed:
// hashes=x y z ...
// feature=<base64>
// field=<cl_ha|ph_ha|...>
String[] hashStrings = params.get("hashes").trim().split(",");
int[] hashes = new int[100];
byte[] featureVector = Base64.decodeBase64(params.get("feature"));
String paramField = "cl_ha";
if (req.getParams().get("field") != null)
paramField = req.getParams().get("field");
int paramRows = defaultNumberOfResults;
if (params.getInt("rows") != null)
paramRows = params.getInt("rows");
numberOfQueryTerms = req.getParams().getDouble("accuracy", DEFAULT_NUMBER_OF_QUERY_TERMS);
numberOfCandidateResults = req.getParams().getInt("candidates", DEFAULT_NUMBER_OF_CANDIDATES);
// create boolean query:
// System.out.println("** Creating query.");
LinkedList<Term> termFilter = new LinkedList<Term>();
BooleanQuery query = new BooleanQuery();
for (int i = 0; i < hashStrings.length; i++) {
hashes[i] = Integer.parseInt(hashStrings[i],16);
// be aware that the hashFunctionsFileName of the field must match the one you put the hashes in before.
// hashStrings[i] = hashStrings[i].trim();
// if (hashStrings[i].length() > 0) {
// termFilter.add(new Term(paramField, hashStrings[i].trim()));
// System.out.println("** " + field + ": " + hashes[i].trim());
// }
}
// Collections.shuffle(termFilter);
// for (int k = 0; k < termFilter.size() * numberOfQueryTerms; k++) {
// query.add(new BooleanClause(new TermQuery(termFilter.get(k)), BooleanClause.Occur.SHOULD));
// }
// System.out.println("** Doing search.");
// query feature
LireFeature queryFeature = (LireFeature) FeatureRegistry.getClassForHashField(paramField).newInstance();
queryFeature.setByteArrayRepresentation(featureVector);
// get results:
// doSearch(req, rsp, searcher, paramField, paramRows, termFilter, new MatchAllDocsQuery(), queryFeature);
doSearch(req, rsp, req.getSearcher(), paramField, paramRows, termFilter, createQuery(hashes, paramField, numberOfQueryTerms), queryFeature);
}
/**
* Actual search implementation based on (i) hash based retrieval and (ii) feature based re-ranking.
*
* @param rsp
* @param searcher
* @param hashFieldName the hash field name
* @param maximumHits
* @param terms
* @param queryFeature
* @throws IOException
* @throws IllegalAccessException
* @throws InstantiationException
*/
private void doSearch(SolrQueryRequest req, SolrQueryResponse rsp, SolrIndexSearcher searcher, String hashFieldName, int maximumHits, List<Term> terms, Query query, LireFeature queryFeature) throws IOException, IllegalAccessException, InstantiationException {
// temp feature instance
LireFeature tmpFeature = queryFeature.getClass().newInstance();
// Taking the time of search for statistical purposes.
time = System.currentTimeMillis();
Filter filter = null;
// if the request contains a filter:
if (req.getParams().get("fq")!=null) {
// only filters with [<field>:<value> ]+ are supported
StringTokenizer st = new StringTokenizer(req.getParams().get("fq"), " ");
LinkedList<Term> filterTerms = new LinkedList<Term>();
while (st.hasMoreElements()) {
String[] tmpToken = st.nextToken().split(":");
if (tmpToken.length>1) {
filterTerms.add(new Term(tmpToken[0], tmpToken[1]));
}
}
if (filterTerms.size()>0)
filter = new TermsFilter(filterTerms);
}
TopDocs docs; // with query only.
if (filter == null) {
docs = searcher.search(query, numberOfCandidateResults);
} else {
docs = searcher.search(query, filter, numberOfCandidateResults);
}
// TopDocs docs = searcher.search(query, new TermsFilter(terms), numberOfCandidateResults); // with TermsFilter and boosting by simple query
// TopDocs docs = searcher.search(new ConstantScoreQuery(new TermsFilter(terms)), numberOfCandidateResults); // just with TermsFilter
time = System.currentTimeMillis() - time;
rsp.add("RawDocsCount", docs.scoreDocs.length + "");
rsp.add("RawDocsSearchTime", time + "");
// re-rank
time = System.currentTimeMillis();
TreeSet<SimpleResult> resultScoreDocs = new TreeSet<SimpleResult>();
float maxDistance = -1f;
float tmpScore;
String featureFieldName = FeatureRegistry.getFeatureFieldName(hashFieldName);
// iterating and re-ranking the documents.
BinaryDocValues binaryValues = MultiDocValues.getBinaryValues(searcher.getIndexReader(), featureFieldName); // *** #
BytesRef bytesRef;// = new BytesRef();
for (int i = 0; i < docs.scoreDocs.length; i++) {
// using DocValues to retrieve the field values ...
bytesRef = binaryValues.get(docs.scoreDocs[i].doc);
tmpFeature.setByteArrayRepresentation(bytesRef.bytes, bytesRef.offset, bytesRef.length);
// Getting the document from the index.
// This is the slow step based on the field compression of stored fields.
// tmpFeature.setByteArrayRepresentation(d.getBinaryValue(name).bytes, d.getBinaryValue(name).offset, d.getBinaryValue(name).length);
tmpScore = queryFeature.getDistance(tmpFeature);
if(tmpScore > 20) continue;
if (resultScoreDocs.size() < maximumHits) { // todo: There's potential here for a memory saver, think of a clever data structure that can do the trick without creating a new SimpleResult for each result.
resultScoreDocs.add(new SimpleResult(tmpScore, searcher.doc(docs.scoreDocs[i].doc), docs.scoreDocs[i].doc));
maxDistance = resultScoreDocs.last().getDistance();
} else if (tmpScore < maxDistance) {
// if it is nearer to the sample than at least one of the current set:
// remove the last one ...
resultScoreDocs.remove(resultScoreDocs.last());
// add the new one ...
resultScoreDocs.add(new SimpleResult(tmpScore, searcher.doc(docs.scoreDocs[i].doc), docs.scoreDocs[i].doc));
// and set our new distance border ...
maxDistance = resultScoreDocs.last().getDistance();
}
}
// System.out.println("** Creating response.");
time = System.currentTimeMillis() - time;
rsp.add("ReRankSearchTime", time + "");
LinkedList list = new LinkedList();
for (Iterator<SimpleResult> it = resultScoreDocs.iterator(); it.hasNext(); ) {
SimpleResult result = it.next();
HashMap m = new HashMap(2);
m.put("d", result.getDistance());
// add fields as requested:
if (req.getParams().get("fl") == null) {
m.put("id", result.getDocument().get("id"));
if (result.getDocument().get("title") != null)
m.put("title", result.getDocument().get("title"));
} else {
String fieldsRequested = req.getParams().get("fl");
if (fieldsRequested.contains("score")) {
m.put("score", result.getDistance());
}
if (fieldsRequested.contains("*")) {
// all fields
for (IndexableField field : result.getDocument().getFields()) {
String tmpField = field.name();
if (result.getDocument().getFields(tmpField).length > 1) {
m.put(result.getDocument().getFields(tmpField)[0].name(), result.getDocument().getValues(tmpField));
} else if (result.getDocument().getFields(tmpField).length > 0) {
m.put(result.getDocument().getFields(tmpField)[0].name(), result.getDocument().getFields(tmpField)[0].stringValue());
}
}
} else {
StringTokenizer st;
if (fieldsRequested.contains(","))
st = new StringTokenizer(fieldsRequested, ",");
else
st = new StringTokenizer(fieldsRequested, " ");
while (st.hasMoreElements()) {
String tmpField = st.nextToken();
if (result.getDocument().getFields(tmpField).length > 1) {
m.put(result.getDocument().getFields(tmpField)[0].name(), result.getDocument().getValues(tmpField));
} else if (result.getDocument().getFields(tmpField).length > 0) {
m.put(result.getDocument().getFields(tmpField)[0].name(), result.getDocument().getFields(tmpField)[0].stringValue());
}
}
}
}
// m.put(field, result.getDocument().get(field));
// m.put(field.replace("_ha", "_hi"), result.getDocument().getBinaryValue(field));
list.add(m);
}
rsp.add("docs", list);
// rsp.add("Test-name", "Test-val");
}
@Override
public String getDescription() {
return "LIRE Request Handler to add images to an index and search them. Search images by id, by url and by extracted features.";
}
@Override
public String getSource() {
return "http://lire-project.net";
}
@Override
public NamedList<Object> getStatistics() {
// Change stats here to get an insight in the admin console.
NamedList<Object> statistics = super.getStatistics();
statistics.add("Number of Requests", countRequests);
return statistics;
}
private BooleanQuery createQuery(int[] hashes, String paramField, double size) {
List<Integer> hList = new ArrayList<Integer>(hashes.length);
try{
PrintWriter writer = new PrintWriter("/tmp/!.txt", "UTF-8");
for (int i = 0; i < hashes.length; i++) {
if(docCount.get(hashes[i]) > 0 && docCount.get(hashes[i]) < 300000000){
writer.println(hashes[i]);
writer.println(docCount.get(hashes[i]));
}
}
writer.close();
} catch (IOException ex) {
}
for (int i = 0; i < hashes.length; i++) {
if(docCount.get(hashes[i]) > 0 && docCount.get(hashes[i]) < 300000000){
hList.add(hashes[i]);
}
}
//remove duplicates
Set<Integer> hs = new HashSet<>();
hs.addAll(hList);
hList.clear();
hList.addAll(hs);
Comparator<Integer> compareByFrequency = new Comparator<Integer>() {
@Override
public int compare(Integer h1, Integer h2) {
int v1 = docCount.get(h1);
int v2 = docCount.get(h2);
return v1 - v2;
}
};
Collections.sort(hList,compareByFrequency);
try{
PrintWriter writer = new PrintWriter("/tmp/tmp.txt", "UTF-8");
for (int i = 0; i < hList.size(); i++) {
//writer.println(hList.get(i));
writer.println(docCount.get(hList.get(i)));
}
writer.close();
} catch (IOException ex) {
}
int[] offsets1 = {0,1,2,3,1,2,1,0,0,0};
int[] offsets2 = {1,2,3,4,3,4,4,2,3,4};
BooleanQuery query = new BooleanQuery();
int offset = (int)(size-1);
if(offset < 4){
query.add(new BooleanClause(new TermQuery(new Term(paramField, Integer.toHexString(hList.get(offsets1[offset])))), BooleanClause.Occur.MUST));
query.add(new BooleanClause(new TermQuery(new Term(paramField, Integer.toHexString(hList.get(offsets2[offset])))), BooleanClause.Occur.MUST));
}
else{
offset = offset - 4;
query.add(new BooleanClause(new TermQuery(new Term(paramField, Integer.toHexString(hList.get(offset)))), BooleanClause.Occur.MUST));
}
return query;
}
/**
* This is used to create a TermsFilter ... should be used to select in the index based on many terms.
* We just need to integrate a minimum query too, else we'd not get the appropriate results.
*
* @param hashes
* @param paramField
* @return
*/
private List<Term> createTermFilter(int[] hashes, String paramField) {
LinkedList<Term> termFilter = new LinkedList<Term>();
for (int i = 0; i < hashes.length; i++) {
// be aware that the hashFunctionsFileName of the field must match the one you put the hashes in before.
termFilter.add(new Term(paramField, Integer.toHexString(hashes[i])));
}
return termFilter;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment