MtasSolrComponentList.java.html
50.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MtasSolrComponentList.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">MTAS</a> > <a href="index.source.html" class="el_package">mtas.solr.handler.component.util</a> > <span class="el_source">MtasSolrComponentList.java</span></div><h1>MtasSolrComponentList.java</h1><pre class="source lang-java linenums">package mtas.solr.handler.component.util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.handler.component.SearchComponent;
import org.apache.solr.handler.component.ShardRequest;
import org.apache.solr.handler.component.ShardResponse;
import mtas.analysis.token.MtasToken;
import mtas.codec.util.CodecUtil;
import mtas.search.spans.util.MtasSpanQuery;
import mtas.codec.util.CodecComponent.ComponentField;
import mtas.codec.util.CodecComponent.ComponentFields;
import mtas.codec.util.CodecComponent.ComponentList;
import mtas.codec.util.CodecComponent.ListHit;
import mtas.codec.util.CodecComponent.ListToken;
import mtas.solr.handler.component.MtasSolrSearchComponent;
/**
* The Class MtasSolrComponentList.
*/
public class MtasSolrComponentList implements MtasSolrComponent<ComponentList> {
/** The Constant log. */
<span class="fc" id="L39"> private static final Log log = LogFactory.getLog(MtasSolrComponentList.class);</span>
/** The search component. */
MtasSolrSearchComponent searchComponent;
/** The Constant PARAM_MTAS_LIST. */
public static final String PARAM_MTAS_LIST = MtasSolrSearchComponent.PARAM_MTAS
+ ".list";
/** The Constant NAME_MTAS_LIST_FIELD. */
public static final String NAME_MTAS_LIST_FIELD = "field";
/** The Constant NAME_MTAS_LIST_QUERY_TYPE. */
public static final String NAME_MTAS_LIST_QUERY_TYPE = "query.type";
/** The Constant NAME_MTAS_LIST_QUERY_VALUE. */
public static final String NAME_MTAS_LIST_QUERY_VALUE = "query.value";
/** The Constant NAME_MTAS_LIST_QUERY_PREFIX. */
public static final String NAME_MTAS_LIST_QUERY_PREFIX = "query.prefix";
/** The Constant NAME_MTAS_LIST_QUERY_IGNORE. */
public static final String NAME_MTAS_LIST_QUERY_IGNORE = "query.ignore";
/** The Constant NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH. */
public static final String NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH = "query.maximumIgnoreLength";
/** The Constant NAME_MTAS_LIST_QUERY_VARIABLE. */
public static final String NAME_MTAS_LIST_QUERY_VARIABLE = "query.variable";
/** The Constant SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME. */
public static final String SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME = "name";
/** The Constant SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE. */
public static final String SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE = "value";
/** The Constant NAME_MTAS_LIST_KEY. */
public static final String NAME_MTAS_LIST_KEY = "key";
/** The Constant NAME_MTAS_LIST_PREFIX. */
public static final String NAME_MTAS_LIST_PREFIX = "prefix";
/** The Constant NAME_MTAS_LIST_START. */
public static final String NAME_MTAS_LIST_START = "start";
/** The Constant NAME_MTAS_LIST_NUMBER. */
public static final String NAME_MTAS_LIST_NUMBER = "number";
/** The Constant NAME_MTAS_LIST_LEFT. */
public static final String NAME_MTAS_LIST_LEFT = "left";
/** The Constant NAME_MTAS_LIST_RIGHT. */
public static final String NAME_MTAS_LIST_RIGHT = "right";
/** The Constant NAME_MTAS_LIST_OUTPUT. */
<span class="fc" id="L94"> public static final String NAME_MTAS_LIST_OUTPUT = "output";</span>
/**
* Instantiates a new mtas solr component list.
*
* @param searchComponent the search component
*/
<span class="fc" id="L101"> public MtasSolrComponentList(MtasSolrSearchComponent searchComponent) {</span>
<span class="fc" id="L102"> this.searchComponent = searchComponent;</span>
<span class="fc" id="L103"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.solr.handler.component.util.MtasSolrComponent#prepare(org.apache.solr.
* handler.component.ResponseBuilder,
* mtas.codec.util.CodecComponent.ComponentFields)
*/
public void prepare(ResponseBuilder rb, ComponentFields mtasFields)
throws IOException {
<span class="nc" id="L115"> Set<String> ids = MtasSolrResultUtil</span>
<span class="nc" id="L116"> .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_LIST);</span>
<span class="nc bnc" id="L117" title="All 2 branches missed."> if (!ids.isEmpty()) {</span>
<span class="nc" id="L118"> int tmpCounter = 0;</span>
<span class="nc" id="L119"> String[] fields = new String[ids.size()];</span>
<span class="nc" id="L120"> String[] queryTypes = new String[ids.size()];</span>
<span class="nc" id="L121"> String[] queryValues = new String[ids.size()];</span>
<span class="nc" id="L122"> String[] queryPrefixes = new String[ids.size()];</span>
<span class="nc" id="L123"> HashMap<String, String[]>[] queryVariables = new HashMap[ids.size()];</span>
<span class="nc" id="L124"> String[] queryIgnores = new String[ids.size()];</span>
<span class="nc" id="L125"> String[] queryMaximumIgnoreLengths = new String[ids.size()];</span>
<span class="nc" id="L126"> String[] keys = new String[ids.size()];</span>
<span class="nc" id="L127"> String[] prefixes = new String[ids.size()];</span>
<span class="nc" id="L128"> String[] starts = new String[ids.size()];</span>
<span class="nc" id="L129"> String[] numbers = new String[ids.size()];</span>
<span class="nc" id="L130"> String[] lefts = new String[ids.size()];</span>
<span class="nc" id="L131"> String[] rights = new String[ids.size()];</span>
<span class="nc" id="L132"> String[] outputs = new String[ids.size()];</span>
<span class="nc bnc" id="L133" title="All 2 branches missed."> for (String id : ids) {</span>
<span class="nc" id="L134"> fields[tmpCounter] = rb.req.getParams()</span>
<span class="nc" id="L135"> .get(PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_FIELD, null);</span>
<span class="nc" id="L136"> keys[tmpCounter] = rb.req.getParams()</span>
<span class="nc" id="L137"> .get(PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_KEY,</span>
<span class="nc" id="L138"> String.valueOf(tmpCounter))</span>
<span class="nc" id="L139"> .trim();</span>
<span class="nc" id="L140"> queryTypes[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L141"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_QUERY_TYPE, null);</span>
<span class="nc" id="L142"> queryValues[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L143"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_QUERY_VALUE,</span>
<span class="nc" id="L144"> null);</span>
<span class="nc" id="L145"> queryPrefixes[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L146"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_QUERY_PREFIX,</span>
<span class="nc" id="L147"> null);</span>
<span class="nc" id="L148"> queryIgnores[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L149"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_QUERY_IGNORE,</span>
<span class="nc" id="L150"> null);</span>
<span class="nc" id="L151"> queryMaximumIgnoreLengths[tmpCounter] = rb.req.getParams()</span>
<span class="nc" id="L152"> .get(PARAM_MTAS_LIST + "." + id + "."</span>
<span class="nc" id="L153"> + NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH, null);</span>
<span class="nc" id="L154"> Set<String> vIds = MtasSolrResultUtil.getIdsFromParameters(</span>
<span class="nc" id="L155"> rb.req.getParams(),</span>
<span class="nc" id="L156"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_QUERY_VARIABLE);</span>
<span class="nc" id="L157"> queryVariables[tmpCounter] = new HashMap<>();</span>
<span class="nc bnc" id="L158" title="All 2 branches missed."> if (!vIds.isEmpty()) {</span>
<span class="nc" id="L159"> HashMap<String, ArrayList<String>> tmpVariables = new HashMap<>();</span>
<span class="nc bnc" id="L160" title="All 2 branches missed."> for (String vId : vIds) {</span>
<span class="nc" id="L161"> String name = rb.req.getParams().get(</span>
<span class="nc" id="L162"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_QUERY_VARIABLE</span>
<span class="nc" id="L163"> + "." + vId + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME,</span>
<span class="nc" id="L164"> null);</span>
<span class="nc bnc" id="L165" title="All 2 branches missed."> if (name != null) {</span>
<span class="nc bnc" id="L166" title="All 2 branches missed."> if (!tmpVariables.containsKey(name)) {</span>
<span class="nc" id="L167"> tmpVariables.put(name, new ArrayList<String>());</span>
}
<span class="nc" id="L169"> String value = rb.req.getParams()</span>
<span class="nc" id="L170"> .get(PARAM_MTAS_LIST + "." + id + "."</span>
<span class="nc" id="L171"> + NAME_MTAS_LIST_QUERY_VARIABLE + "." + vId + "."</span>
<span class="nc" id="L172"> + SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE, null);</span>
<span class="nc bnc" id="L173" title="All 2 branches missed."> if (value != null) {</span>
<span class="nc" id="L174"> ArrayList<String> list = new ArrayList<>();</span>
<span class="nc" id="L175"> String[] subList = value.split("(?<!\\\\),");</span>
<span class="nc bnc" id="L176" title="All 2 branches missed."> for (int i = 0; i < subList.length; i++) {</span>
<span class="nc" id="L177"> list.add(</span>
<span class="nc" id="L178"> subList[i].replace("\\,", ",").replace("\\\\", "\\"));</span>
}
<span class="nc" id="L180"> tmpVariables.get(name).addAll(list);</span>
}
}
}
<span class="nc bnc" id="L184" title="All 2 branches missed."> for (Entry<String, ArrayList<String>> entry : tmpVariables</span>
<span class="nc" id="L185"> .entrySet()) {</span>
<span class="nc" id="L186"> queryVariables[tmpCounter].put(entry.getKey(),</span>
<span class="nc" id="L187"> entry.getValue().toArray(new String[entry.getValue().size()]));</span>
}
}
<span class="nc" id="L190"> prefixes[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L191"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_PREFIX, null);</span>
<span class="nc" id="L192"> starts[tmpCounter] = rb.req.getParams()</span>
<span class="nc" id="L193"> .get(PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_START, null);</span>
<span class="nc" id="L194"> numbers[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L195"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_NUMBER, null);</span>
<span class="nc" id="L196"> lefts[tmpCounter] = rb.req.getParams()</span>
<span class="nc" id="L197"> .get(PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_LEFT, null);</span>
<span class="nc" id="L198"> rights[tmpCounter] = rb.req.getParams()</span>
<span class="nc" id="L199"> .get(PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_RIGHT, null);</span>
<span class="nc" id="L200"> outputs[tmpCounter] = rb.req.getParams().get(</span>
<span class="nc" id="L201"> PARAM_MTAS_LIST + "." + id + "." + NAME_MTAS_LIST_OUTPUT, null);</span>
<span class="nc" id="L202"> tmpCounter++;</span>
}
<span class="nc" id="L204"> String uniqueKeyField = rb.req.getSchema().getUniqueKeyField().getName();</span>
<span class="nc" id="L205"> mtasFields.doList = true;</span>
<span class="nc" id="L206"> rb.setNeedDocSet(true);</span>
<span class="nc bnc" id="L207" title="All 2 branches missed."> for (String field : fields) {</span>
<span class="nc bnc" id="L208" title="All 4 branches missed."> if (field == null || field.isEmpty()) {</span>
<span class="nc" id="L209"> throw new IOException("no (valid) field in mtas list");</span>
<span class="nc bnc" id="L210" title="All 2 branches missed."> } else if (!mtasFields.list.containsKey(field)) {</span>
<span class="nc" id="L211"> mtasFields.list.put(field, new ComponentField(uniqueKeyField));</span>
}
}
<span class="nc" id="L214"> MtasSolrResultUtil.compareAndCheck(keys, fields, NAME_MTAS_LIST_KEY,</span>
<span class="nc" id="L215"> NAME_MTAS_LIST_FIELD, true);</span>
<span class="nc" id="L216"> MtasSolrResultUtil.compareAndCheck(prefixes, queryValues,</span>
<span class="nc" id="L217"> NAME_MTAS_LIST_QUERY_VALUE, NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L218"> MtasSolrResultUtil.compareAndCheck(prefixes, queryTypes,</span>
<span class="nc" id="L219"> NAME_MTAS_LIST_QUERY_TYPE, NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L220"> MtasSolrResultUtil.compareAndCheck(prefixes, queryPrefixes,</span>
<span class="nc" id="L221"> NAME_MTAS_LIST_QUERY_PREFIX, NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L222"> MtasSolrResultUtil.compareAndCheck(prefixes, queryIgnores,</span>
<span class="nc" id="L223"> NAME_MTAS_LIST_QUERY_IGNORE, NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L224"> MtasSolrResultUtil.compareAndCheck(prefixes, queryMaximumIgnoreLengths,</span>
<span class="nc" id="L225"> NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH, NAME_MTAS_LIST_FIELD,</span>
<span class="nc" id="L226"> false);</span>
<span class="nc" id="L227"> MtasSolrResultUtil.compareAndCheck(prefixes, fields,</span>
<span class="nc" id="L228"> NAME_MTAS_LIST_PREFIX, NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L229"> MtasSolrResultUtil.compareAndCheck(starts, fields, NAME_MTAS_LIST_START,</span>
<span class="nc" id="L230"> NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L231"> MtasSolrResultUtil.compareAndCheck(numbers, fields, NAME_MTAS_LIST_NUMBER,</span>
<span class="nc" id="L232"> NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L233"> MtasSolrResultUtil.compareAndCheck(lefts, fields, NAME_MTAS_LIST_LEFT,</span>
<span class="nc" id="L234"> NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L235"> MtasSolrResultUtil.compareAndCheck(rights, fields, NAME_MTAS_LIST_RIGHT,</span>
<span class="nc" id="L236"> NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc" id="L237"> MtasSolrResultUtil.compareAndCheck(outputs, fields, NAME_MTAS_LIST_OUTPUT,</span>
<span class="nc" id="L238"> NAME_MTAS_LIST_FIELD, false);</span>
<span class="nc bnc" id="L239" title="All 2 branches missed."> for (int i = 0; i < fields.length; i++) {</span>
<span class="nc" id="L240"> ComponentField cf = mtasFields.list.get(fields[i]);</span>
<span class="nc bnc" id="L241" title="All 2 branches missed."> Integer maximumIgnoreLength = (queryMaximumIgnoreLengths[i] == null)</span>
<span class="nc" id="L242"> ? null : Integer.parseInt(queryMaximumIgnoreLengths[i]);</span>
<span class="nc" id="L243"> MtasSpanQuery q = MtasSolrResultUtil.constructQuery(queryValues[i],</span>
<span class="nc" id="L244"> queryTypes[i], queryPrefixes[i], queryVariables[i], fields[i],</span>
<span class="nc" id="L245"> queryIgnores[i], maximumIgnoreLength);</span>
// minimize number of queries
<span class="nc bnc" id="L247" title="All 2 branches missed."> if (cf.spanQueryList.contains(q)) {</span>
<span class="nc" id="L248"> q = cf.spanQueryList.get(cf.spanQueryList.indexOf(q));</span>
<span class="nc" id="L249"> } else {</span>
<span class="nc" id="L250"> cf.spanQueryList.add(q);</span>
}
<span class="nc bnc" id="L252" title="All 4 branches missed."> String key = (keys[i] == null) || (keys[i].isEmpty())</span>
<span class="nc" id="L253"> ? String.valueOf(i) + ":" + fields[i] + ":" + queryValues[i] + ":"</span>
<span class="nc" id="L254"> + queryPrefixes[i]</span>
<span class="nc" id="L255"> : keys[i].trim();</span>
<span class="nc" id="L256"> String prefix = prefixes[i];</span>
<span class="nc bnc" id="L257" title="All 4 branches missed."> int start = (starts[i] == null) || (starts[i].isEmpty()) ? 0</span>
<span class="nc" id="L258"> : Integer.parseInt(starts[i]);</span>
<span class="nc bnc" id="L259" title="All 4 branches missed."> int number = (numbers[i] == null) || (numbers[i].isEmpty()) ? 10</span>
<span class="nc" id="L260"> : Integer.parseInt(numbers[i]);</span>
<span class="nc bnc" id="L261" title="All 4 branches missed."> int left = (lefts[i] == null) || lefts[i].isEmpty() ? 0</span>
<span class="nc" id="L262"> : Integer.parseInt(lefts[i]);</span>
<span class="nc bnc" id="L263" title="All 4 branches missed."> int right = (rights[i] == null) || rights[i].isEmpty() ? 0</span>
<span class="nc" id="L264"> : Integer.parseInt(rights[i]);</span>
<span class="nc" id="L265"> String output = outputs[i];</span>
<span class="nc" id="L266"> mtasFields.list.get(fields[i]).listList.add(new ComponentList(q,</span>
<span class="nc" id="L267"> fields[i], queryValues[i], queryTypes[i], queryPrefixes[i],</span>
<span class="nc" id="L268"> queryVariables[i], queryIgnores[i], queryMaximumIgnoreLengths[i],</span>
<span class="nc" id="L269"> key, prefix, start, number, left, right, output));</span>
}
}
<span class="nc" id="L272"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.solr.handler.component.util.MtasSolrComponent#modifyRequest(org.apache
* .solr.handler.component.ResponseBuilder,
* org.apache.solr.handler.component.SearchComponent,
* org.apache.solr.handler.component.ShardRequest)
*/
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
ShardRequest sreq) {
<span class="nc bnc" id="L285" title="All 2 branches missed."> if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)</span>
<span class="nc bnc" id="L286" title="All 2 branches missed."> && sreq.params.getBool(PARAM_MTAS_LIST, false)) {</span>
// compute keys
<span class="nc" id="L288"> Set<String> keys = MtasSolrResultUtil</span>
<span class="nc" id="L289"> .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_LIST);</span>
<span class="nc bnc" id="L290" title="All 2 branches missed."> if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {</span>
<span class="nc bnc" id="L291" title="All 2 branches missed."> for (String key : keys) {</span>
<span class="nc" id="L292"> sreq.params.remove(</span>
<span class="nc" id="L293"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_PREFIX);</span>
<span class="nc" id="L294"> sreq.params</span>
<span class="nc" id="L295"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_START);</span>
<span class="nc" id="L296"> sreq.params.remove(</span>
<span class="nc" id="L297"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_NUMBER);</span>
<span class="nc" id="L298"> sreq.params</span>
<span class="nc" id="L299"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_LEFT);</span>
<span class="nc" id="L300"> sreq.params</span>
<span class="nc" id="L301"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_RIGHT);</span>
<span class="nc" id="L302"> sreq.params.remove(</span>
<span class="nc" id="L303"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_OUTPUT);</span>
// don't get data
<span class="nc" id="L305"> sreq.params.add(</span>
<span class="nc" id="L306"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_NUMBER, "0");</span>
}
<span class="nc" id="L308"> } else {</span>
<span class="nc" id="L309"> sreq.params.remove(PARAM_MTAS_LIST);</span>
<span class="nc bnc" id="L310" title="All 2 branches missed."> for (String key : keys) {</span>
<span class="nc" id="L311"> sreq.params</span>
<span class="nc" id="L312"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_FIELD);</span>
<span class="nc" id="L313"> sreq.params.remove(</span>
<span class="nc" id="L314"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_VALUE);</span>
<span class="nc" id="L315"> sreq.params.remove(</span>
<span class="nc" id="L316"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_TYPE);</span>
<span class="nc" id="L317"> sreq.params.remove(</span>
<span class="nc" id="L318"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_PREFIX);</span>
<span class="nc" id="L319"> sreq.params.remove(</span>
<span class="nc" id="L320"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_IGNORE);</span>
<span class="nc" id="L321"> sreq.params.remove(PARAM_MTAS_LIST + "." + key + "."</span>
<span class="nc" id="L322"> + NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH);</span>
<span class="nc" id="L323"> Set<String> subKeys = MtasSolrResultUtil</span>
<span class="nc" id="L324"> .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_LIST + "."</span>
<span class="nc" id="L325"> + key + "." + NAME_MTAS_LIST_QUERY_VARIABLE);</span>
<span class="nc bnc" id="L326" title="All 2 branches missed."> for (String subKey : subKeys) {</span>
<span class="nc" id="L327"> sreq.params.remove(PARAM_MTAS_LIST + "." + key + "."</span>
<span class="nc" id="L328"> + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subKey + "."</span>
<span class="nc" id="L329"> + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME);</span>
<span class="nc" id="L330"> sreq.params.remove(PARAM_MTAS_LIST + "." + key + "."</span>
<span class="nc" id="L331"> + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subKey + "."</span>
<span class="nc" id="L332"> + SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE);</span>
}
<span class="nc" id="L334"> sreq.params</span>
<span class="nc" id="L335"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_KEY);</span>
<span class="nc" id="L336"> sreq.params.remove(</span>
<span class="nc" id="L337"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_PREFIX);</span>
<span class="nc" id="L338"> sreq.params</span>
<span class="nc" id="L339"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_START);</span>
<span class="nc" id="L340"> sreq.params.remove(</span>
<span class="nc" id="L341"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_NUMBER);</span>
<span class="nc" id="L342"> sreq.params</span>
<span class="nc" id="L343"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_LEFT);</span>
<span class="nc" id="L344"> sreq.params</span>
<span class="nc" id="L345"> .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_RIGHT);</span>
<span class="nc" id="L346"> sreq.params.remove(</span>
<span class="nc" id="L347"> PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_OUTPUT);</span>
}
}
}
<span class="nc" id="L351"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.solr.handler.component.util.MtasSolrComponent#distributedProcess(org.
* apache.solr.handler.component.ResponseBuilder,
* mtas.codec.util.CodecComponent.ComponentFields)
*/
@SuppressWarnings("unchecked")
public void distributedProcess(ResponseBuilder rb,
ComponentFields mtasFields) {
<span class="nc bnc" id="L365" title="All 2 branches missed."> if (mtasFields.doList) {</span>
// compute total from shards
<span class="nc" id="L367"> HashMap<String, HashMap<String, Integer>> listShardTotals = new HashMap<>();</span>
<span class="nc bnc" id="L368" title="All 2 branches missed."> for (ShardRequest sreq : rb.finished) {</span>
<span class="nc bnc" id="L369" title="All 2 branches missed."> if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)</span>
<span class="nc bnc" id="L370" title="All 2 branches missed."> && sreq.params.getBool(PARAM_MTAS_LIST, false)) {</span>
<span class="nc bnc" id="L371" title="All 2 branches missed."> for (ShardResponse response : sreq.responses) {</span>
<span class="nc" id="L372"> NamedList<Object> result = response.getSolrResponse().getResponse();</span>
try {
<span class="nc" id="L374"> ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) result</span>
<span class="nc" id="L375"> .findRecursive("mtas", "list");</span>
<span class="nc bnc" id="L376" title="All 2 branches missed."> if (data != null) {</span>
<span class="nc bnc" id="L377" title="All 2 branches missed."> for (NamedList<Object> dataItem : data) {</span>
<span class="nc" id="L378"> Object key = dataItem.get("key");</span>
<span class="nc" id="L379"> Object total = dataItem.get("total");</span>
<span class="nc bnc" id="L380" title="All 4 branches missed."> if ((key != null) && (key instanceof String)</span>
<span class="nc bnc" id="L381" title="All 4 branches missed."> && (total != null) && (total instanceof Integer)) {</span>
<span class="nc bnc" id="L382" title="All 2 branches missed."> if (!listShardTotals.containsKey(key)) {</span>
<span class="nc" id="L383"> listShardTotals.put((String) key,</span>
<span class="nc" id="L384"> new HashMap<String, Integer>());</span>
}
<span class="nc" id="L386"> HashMap<String, Integer> listShardTotal = listShardTotals</span>
<span class="nc" id="L387"> .get(key);</span>
<span class="nc" id="L388"> listShardTotal.put(response.getShard(), (Integer) total);</span>
}
}
}
<span class="nc" id="L392"> } catch (ClassCastException e) {</span>
<span class="nc" id="L393"> log.debug(e);</span>
}
}
}
}
// compute shard requests
<span class="nc" id="L399"> HashMap<String, ModifiableSolrParams> shardRequests = new HashMap<>();</span>
<span class="nc" id="L400"> int requestId = 0;</span>
<span class="nc bnc" id="L401" title="All 2 branches missed."> for (String field : mtasFields.list.keySet()) {</span>
<span class="nc bnc" id="L402" title="All 2 branches missed."> for (ComponentList list : mtasFields.list.get(field).listList) {</span>
<span class="nc" id="L403"> requestId++;</span>
<span class="nc bnc" id="L404" title="All 4 branches missed."> if (listShardTotals.containsKey(list.key) && (list.number > 0)) {</span>
<span class="nc" id="L405"> Integer start = list.start;</span>
<span class="nc" id="L406"> Integer number = list.number;</span>
<span class="nc" id="L407"> HashMap<String, Integer> totals = listShardTotals.get(list.key);</span>
<span class="nc bnc" id="L408" title="All 2 branches missed."> for (int i = 0; i < rb.shards.length; i++) {</span>
<span class="nc bnc" id="L409" title="All 2 branches missed."> if (number < 0) {</span>
<span class="nc" id="L410"> break;</span>
}
<span class="nc" id="L412"> int subTotal = totals.get(rb.shards[i]);</span>
// System.out.println(i + " : " + rb.shards[i] + " : "
// + totals.get(rb.shards[i]) + " - " + start + " " + number);
<span class="nc bnc" id="L415" title="All 4 branches missed."> if ((start >= 0) && (start < subTotal)) {</span>
ModifiableSolrParams params;
<span class="nc bnc" id="L417" title="All 2 branches missed."> if (!shardRequests.containsKey(rb.shards[i])) {</span>
<span class="nc" id="L418"> shardRequests.put(rb.shards[i], new ModifiableSolrParams());</span>
}
<span class="nc" id="L420"> params = shardRequests.get(rb.shards[i]);</span>
<span class="nc" id="L421"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L422"> + NAME_MTAS_LIST_FIELD, list.field);</span>
<span class="nc" id="L423"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L424"> + NAME_MTAS_LIST_QUERY_VALUE, list.queryValue);</span>
<span class="nc" id="L425"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L426"> + NAME_MTAS_LIST_QUERY_TYPE, list.queryType);</span>
<span class="nc" id="L427"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L428"> + NAME_MTAS_LIST_QUERY_PREFIX, list.queryPrefix);</span>
<span class="nc" id="L429"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L430"> + NAME_MTAS_LIST_QUERY_IGNORE, list.queryIgnore);</span>
<span class="nc" id="L431"> params.add(</span>
<span class="nc" id="L432"> PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L433"> + NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH,</span>
<span class="nc" id="L434"> list.queryMaximumIgnoreLength);</span>
<span class="nc" id="L435"> int subRequestId = 0;</span>
<span class="nc bnc" id="L436" title="All 2 branches missed."> for (String name : list.queryVariables.keySet()) {</span>
<span class="nc bnc" id="L437" title="All 2 branches missed."> if (list.queryVariables.get(name) == null</span>
<span class="nc bnc" id="L438" title="All 2 branches missed."> || list.queryVariables.get(name).length == 0) {</span>
<span class="nc" id="L439"> params.add(</span>
<span class="nc" id="L440"> PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L441"> + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subRequestId</span>
<span class="nc" id="L442"> + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME,</span>
<span class="nc" id="L443"> name);</span>
<span class="nc" id="L444"> subRequestId++;</span>
<span class="nc" id="L445"> } else {</span>
<span class="nc bnc" id="L446" title="All 2 branches missed."> for (String value : list.queryVariables.get(name)) {</span>
<span class="nc" id="L447"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L448"> + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subRequestId</span>
<span class="nc" id="L449"> + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME, name);</span>
<span class="nc" id="L450"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L451"> + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subRequestId</span>
<span class="nc" id="L452"> + "." + SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE,</span>
<span class="nc" id="L453"> value);</span>
<span class="nc" id="L454"> subRequestId++;</span>
}
}
}
<span class="nc" id="L458"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L459"> + NAME_MTAS_LIST_KEY, list.key);</span>
<span class="nc" id="L460"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L461"> + NAME_MTAS_LIST_PREFIX, list.prefix);</span>
<span class="nc" id="L462"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L463"> + NAME_MTAS_LIST_START, Integer.toString(start));</span>
<span class="nc" id="L464"> params.add(</span>
<span class="nc" id="L465"> PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L466"> + NAME_MTAS_LIST_NUMBER,</span>
<span class="nc" id="L467"> Integer.toString(Math.min(number, (subTotal - start))));</span>
<span class="nc" id="L468"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L469"> + NAME_MTAS_LIST_LEFT, Integer.toString(list.left));</span>
<span class="nc" id="L470"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L471"> + NAME_MTAS_LIST_RIGHT, Integer.toString(list.right));</span>
<span class="nc" id="L472"> params.add(PARAM_MTAS_LIST + "." + requestId + "."</span>
<span class="nc" id="L473"> + NAME_MTAS_LIST_OUTPUT, list.output);</span>
<span class="nc" id="L474"> number -= (subTotal - start);</span>
<span class="nc" id="L475"> start = 0;</span>
<span class="nc" id="L476"> } else {</span>
<span class="nc" id="L477"> start -= subTotal;</span>
}
}
}
}
}
<span class="nc bnc" id="L484" title="All 2 branches missed."> for (Entry<String, ModifiableSolrParams> entry : shardRequests</span>
<span class="nc" id="L485"> .entrySet()) {</span>
<span class="nc" id="L486"> ShardRequest sreq = new ShardRequest();</span>
<span class="nc" id="L487"> sreq.shards = new String[] { entry.getKey() };</span>
<span class="nc" id="L488"> sreq.purpose = ShardRequest.PURPOSE_PRIVATE;</span>
<span class="nc" id="L489"> sreq.params = new ModifiableSolrParams();</span>
<span class="nc" id="L490"> sreq.params.add("fq", rb.req.getParams().getParams("fq"));</span>
<span class="nc" id="L491"> sreq.params.add("q", rb.req.getParams().getParams("q"));</span>
<span class="nc" id="L492"> sreq.params.add("cache", rb.req.getParams().getParams("cache"));</span>
<span class="nc" id="L493"> sreq.params.add("rows", "0");</span>
<span class="nc" id="L494"> sreq.params.add(MtasSolrSearchComponent.PARAM_MTAS, rb.req</span>
<span class="nc" id="L495"> .getOriginalParams().getParams(MtasSolrSearchComponent.PARAM_MTAS));</span>
<span class="nc" id="L496"> sreq.params.add(PARAM_MTAS_LIST,</span>
<span class="nc" id="L497"> rb.req.getOriginalParams().getParams(PARAM_MTAS_LIST));</span>
<span class="nc" id="L498"> sreq.params.add(entry.getValue());</span>
<span class="nc" id="L499"> rb.addRequest(searchComponent, sreq);</span>
}
}
<span class="nc" id="L502"> }</span>
/*
* (non-Javadoc)
*
* @see
* mtas.solr.handler.component.util.MtasSolrComponent#create(mtas.codec.util.
* CodecComponent.BasicComponent, java.lang.Boolean)
*/
public SimpleOrderedMap<Object> create(ComponentList list, Boolean encode) {
<span class="nc" id="L512"> SimpleOrderedMap<Object> mtasListResponse = new SimpleOrderedMap<>();</span>
<span class="nc" id="L513"> mtasListResponse.add("key", list.key);</span>
<span class="nc bnc" id="L514" title="All 2 branches missed."> if (list.number == 0) {</span>
<span class="nc" id="L515"> mtasListResponse.add("total", list.total);</span>
}
<span class="nc bnc" id="L517" title="All 2 branches missed."> if (list.output != null) {</span>
<span class="nc" id="L518"> ArrayList<NamedList<Object>> mtasListItemResponses = new ArrayList<>();</span>
<span class="nc bnc" id="L519" title="All 2 branches missed."> if (list.output.equals(ComponentList.LIST_OUTPUT_HIT)) {</span>
<span class="nc" id="L520"> mtasListResponse.add("number", list.hits.size());</span>
<span class="nc bnc" id="L521" title="All 2 branches missed."> for (ListHit hit : list.hits) {</span>
<span class="nc" id="L522"> NamedList<Object> mtasListItemResponse = new SimpleOrderedMap<>();</span>
<span class="nc" id="L523"> mtasListItemResponse.add("documentKey",</span>
<span class="nc" id="L524"> list.uniqueKey.get(hit.docId));</span>
<span class="nc" id="L525"> mtasListItemResponse.add("documentHitPosition", hit.docPosition);</span>
<span class="nc" id="L526"> mtasListItemResponse.add("documentHitTotal",</span>
<span class="nc" id="L527"> list.subTotal.get(hit.docId));</span>
<span class="nc" id="L528"> mtasListItemResponse.add("documentMinPosition",</span>
<span class="nc" id="L529"> list.minPosition.get(hit.docId));</span>
<span class="nc" id="L530"> mtasListItemResponse.add("documentMaxPosition",</span>
<span class="nc" id="L531"> list.maxPosition.get(hit.docId));</span>
<span class="nc" id="L532"> mtasListItemResponse.add("startPosition", hit.startPosition);</span>
<span class="nc" id="L533"> mtasListItemResponse.add("endPosition", hit.endPosition);</span>
<span class="nc" id="L535"> SortedMap<Integer, List<List<String>>> hitData = new TreeMap<>();</span>
<span class="nc" id="L536"> SortedMap<Integer, List<List<String>>> leftData = null;</span>
<span class="nc" id="L537"> SortedMap<Integer, List<List<String>>> rightData = null;</span>
<span class="nc bnc" id="L538" title="All 2 branches missed."> if (list.left > 0) {</span>
<span class="nc" id="L539"> leftData = new TreeMap<>();</span>
}
<span class="nc bnc" id="L541" title="All 2 branches missed."> if (list.right > 0) {</span>
<span class="nc" id="L542"> rightData = new TreeMap<>();</span>
}
<span class="nc bnc" id="L544" title="All 2 branches missed."> for (int position = Math.max(0,</span>
<span class="nc" id="L545"> hit.startPosition - list.left); position <= (hit.endPosition</span>
<span class="nc" id="L546"> + list.right); position++) {</span>
<span class="nc" id="L547"> List<List<String>> hitDataItem = new ArrayList<>();</span>
<span class="nc bnc" id="L548" title="All 2 branches missed."> if (hit.hits.containsKey(position)) {</span>
<span class="nc bnc" id="L549" title="All 2 branches missed."> for (String term : hit.hits.get(position)) {</span>
<span class="nc" id="L550"> List<String> hitDataSubItem = new ArrayList<>();</span>
<span class="nc" id="L551"> hitDataSubItem.add(CodecUtil.termPrefix(term));</span>
<span class="nc" id="L552"> hitDataSubItem.add(CodecUtil.termValue(term));</span>
<span class="nc" id="L553"> hitDataItem.add(hitDataSubItem);</span>
}
}
<span class="nc bnc" id="L556" title="All 2 branches missed."> if (position < hit.startPosition) {</span>
<span class="nc bnc" id="L557" title="All 2 branches missed."> if (leftData != null) {</span>
<span class="nc" id="L558"> leftData.put(position, hitDataItem);</span>
}
<span class="nc bnc" id="L560" title="All 2 branches missed."> } else if (position > hit.endPosition) {</span>
<span class="nc bnc" id="L561" title="All 2 branches missed."> if (rightData != null) {</span>
<span class="nc" id="L562"> rightData.put(position, hitDataItem);</span>
}
<span class="nc" id="L564"> } else {</span>
<span class="nc" id="L565"> hitData.put(position, hitDataItem);</span>
}
}
<span class="nc bnc" id="L568" title="All 2 branches missed."> if (list.left > 0) {</span>
<span class="nc" id="L569"> mtasListItemResponse.add("left", leftData);</span>
}
<span class="nc" id="L571"> mtasListItemResponse.add("hit", hitData);</span>
<span class="nc bnc" id="L572" title="All 2 branches missed."> if (list.right > 0) {</span>
<span class="nc" id="L573"> mtasListItemResponse.add("right", rightData);</span>
}
<span class="nc" id="L575"> mtasListItemResponses.add(mtasListItemResponse);</span>
}
<span class="nc bnc" id="L577" title="All 2 branches missed."> } else if (list.output.equals(ComponentList.LIST_OUTPUT_TOKEN)) {</span>
<span class="nc" id="L578"> mtasListResponse.add("number", list.tokens.size());</span>
<span class="nc bnc" id="L579" title="All 2 branches missed."> for (ListToken tokenHit : list.tokens) {</span>
<span class="nc" id="L580"> NamedList<Object> mtasListItemResponse = new SimpleOrderedMap<>();</span>
<span class="nc" id="L581"> mtasListItemResponse.add("documentKey",</span>
<span class="nc" id="L582"> list.uniqueKey.get(tokenHit.docId));</span>
<span class="nc" id="L583"> mtasListItemResponse.add("documentHitPosition", tokenHit.docPosition);</span>
<span class="nc" id="L584"> mtasListItemResponse.add("documentHitTotal",</span>
<span class="nc" id="L585"> list.subTotal.get(tokenHit.docId));</span>
<span class="nc" id="L586"> mtasListItemResponse.add("documentMinPosition",</span>
<span class="nc" id="L587"> list.minPosition.get(tokenHit.docId));</span>
<span class="nc" id="L588"> mtasListItemResponse.add("documentMaxPosition",</span>
<span class="nc" id="L589"> list.maxPosition.get(tokenHit.docId));</span>
<span class="nc" id="L590"> mtasListItemResponse.add("startPosition", tokenHit.startPosition);</span>
<span class="nc" id="L591"> mtasListItemResponse.add("endPosition", tokenHit.endPosition);</span>
<span class="nc" id="L593"> ArrayList<NamedList<Object>> mtasListItemResponseItemTokens = new ArrayList<>();</span>
<span class="nc bnc" id="L594" title="All 2 branches missed."> for (MtasToken token : tokenHit.tokens) {</span>
<span class="nc" id="L595"> NamedList<Object> mtasListItemResponseItemToken = new SimpleOrderedMap<>();</span>
<span class="nc bnc" id="L596" title="All 2 branches missed."> if (token.getId() != null) {</span>
<span class="nc" id="L597"> mtasListItemResponseItemToken.add("mtasId", token.getId());</span>
}
<span class="nc" id="L599"> mtasListItemResponseItemToken.add("prefix", token.getPrefix());</span>
<span class="nc" id="L600"> mtasListItemResponseItemToken.add("value", token.getPostfix());</span>
<span class="nc bnc" id="L601" title="All 2 branches missed."> if (token.getPositionStart() != null) {</span>
<span class="nc" id="L602"> mtasListItemResponseItemToken.add("positionStart",</span>
<span class="nc" id="L603"> token.getPositionStart());</span>
<span class="nc" id="L604"> mtasListItemResponseItemToken.add("positionEnd",</span>
<span class="nc" id="L605"> token.getPositionEnd());</span>
}
<span class="nc bnc" id="L607" title="All 2 branches missed."> if (token.getPositions() != null) {</span>
<span class="nc" id="L608"> mtasListItemResponseItemToken.add("positions",</span>
<span class="nc" id="L609"> Arrays.toString(token.getPositions()));</span>
}
<span class="nc bnc" id="L611" title="All 2 branches missed."> if (token.getParentId() != null) {</span>
<span class="nc" id="L612"> mtasListItemResponseItemToken.add("parentMtasId",</span>
<span class="nc" id="L613"> token.getParentId());</span>
}
<span class="nc bnc" id="L615" title="All 2 branches missed."> if (token.getPayload() != null) {</span>
<span class="nc" id="L616"> mtasListItemResponseItemToken.add("payload", token.getPayload());</span>
}
<span class="nc bnc" id="L618" title="All 2 branches missed."> if (token.getOffsetStart() != null) {</span>
<span class="nc" id="L619"> mtasListItemResponseItemToken.add("offsetStart",</span>
<span class="nc" id="L620"> token.getOffsetStart());</span>
<span class="nc" id="L621"> mtasListItemResponseItemToken.add("offsetEnd",</span>
<span class="nc" id="L622"> token.getOffsetEnd());</span>
}
<span class="nc bnc" id="L624" title="All 2 branches missed."> if (token.getRealOffsetStart() != null) {</span>
<span class="nc" id="L625"> mtasListItemResponseItemToken.add("realOffsetStart",</span>
<span class="nc" id="L626"> token.getRealOffsetStart());</span>
<span class="nc" id="L627"> mtasListItemResponseItemToken.add("realOffsetEnd",</span>
<span class="nc" id="L628"> token.getRealOffsetEnd());</span>
}
<span class="nc" id="L630"> mtasListItemResponseItemTokens.add(mtasListItemResponseItemToken);</span>
}
<span class="nc" id="L632"> mtasListItemResponse.add("tokens", mtasListItemResponseItemTokens);</span>
<span class="nc" id="L633"> mtasListItemResponses.add(mtasListItemResponse);</span>
}
}
<span class="nc" id="L636"> mtasListResponse.add("list", mtasListItemResponses);</span>
}
<span class="nc" id="L638"> return mtasListResponse;</span>
}
/*
* (non-Javadoc)
*
* @see
* mtas.solr.handler.component.util.MtasSolrComponent#finishStage(org.apache.
* solr.handler.component.ResponseBuilder)
*/
public void finishStage(ResponseBuilder rb) {
<span class="nc bnc" id="L649" title="All 2 branches missed."> if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false)</span>
<span class="nc bnc" id="L650" title="All 2 branches missed."> && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY</span>
<span class="nc bnc" id="L651" title="All 2 branches missed."> && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) {</span>
<span class="nc bnc" id="L652" title="All 2 branches missed."> for (ShardRequest sreq : rb.finished) {</span>
<span class="nc bnc" id="L653" title="All 2 branches missed."> if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)</span>
<span class="nc" id="L654"> && sreq.params.getBool(PARAM_MTAS_LIST, false)) {</span>
// nothing to do
}
}
}
<span class="nc" id="L659"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>