Commit 273865b35729a50485279b82ce40b0c4dc97ae7a

Authored by Matthijs Brouwer
1 parent 1cb113b7

updates

Showing 29 changed files with 2305 additions and 1058 deletions

Too many changes to show.

To preserve performance only 23 of 29 files are displayed.

.gitignore
... ... @@ -15,3 +15,4 @@ examples/
15 15 demo/
16 16 generated-sources/*
17 17 release.properties
  18 +testindexMtas
... ...
conf/parser/mtas.xml
... ... @@ -4,7 +4,7 @@
4 4 <configuration name="test" file="mtas/folia_test.xml" />
5 5 <configuration name="TEST" file="mtas/folia_dbnl.xml" />
6 6 <configuration name="CRM" file="mtas/crm.xml" />
7   - <configuration name="CGR" file="mtas/crm.xml" />
  7 + <configuration name="CGR" file="mtas/cgr.xml" />
8 8 <configuration name="DBNL" file="mtas/folia_dbnl.xml" />
9 9 <configuration name="DDD" file="mtas/folia_ddd.xml" />
10 10 <configuration name="EDBO" file="mtas/folia_edbo.xml" />
... ...
conf/parser/mtas/crm.xml
... ... @@ -22,7 +22,13 @@
22 22 <makeunique value="true" />
23 23 <!-- END GENERAL SETTINGS MTAS PARSER -->
24 24  
25   - <mappings>
  25 + <filters>
  26 + <filter type="replace" name="4" value="*" replace="" />
  27 + <filter type="replace" name="4" value="#" replace="" />
  28 + </filters>
  29 +
  30 +
  31 + <mappings>
26 32  
27 33 <mapping type="word">
28 34 </mapping>
... ...
conf/solr/solrconfig.xml
... ... @@ -1191,7 +1191,7 @@
1191 1191 </requestHandler>
1192 1192  
1193 1193 <requestHandler name="/mtas"
1194   - class="mtas.solr.handler.MtasRequestHandler" />
  1194 + class="mtas.solr.handler.MtasRequestHandler"/>
1195 1195  
1196 1196 <!-- Clustering Component. (Omitted here. See the default Solr example for a typical configuration.) -->
1197 1197  
... ...
src/main/java/mtas/analysis/parser/MtasCRMParser.java
... ... @@ -52,6 +52,8 @@ public class MtasCRMParser extends MtasBasicParser {
52 52 /** The functions. */
53 53 private HashMap<String, HashMap<String, MtasCRMParserFunction>> functions = new HashMap<>();
54 54  
  55 + private HashMap<Integer, HashMap<String, String>> filterReplace = new HashMap<>();
  56 +
55 57 /** The Constant MAPPING_TYPE_CRM_SENTENCE. */
56 58 protected static final String MAPPING_TYPE_CRM_SENTENCE = "crmSentence";
57 59  
... ... @@ -61,6 +63,9 @@ public class MtasCRMParser extends MtasBasicParser {
61 63 /** The Constant MAPPING_TYPE_CRM_PAIR. */
62 64 protected static final String MAPPING_TYPE_CRM_PAIR = "crmPair";
63 65  
  66 + protected static final String FILTER_TYPE_REPLACE = "replace";
  67 +
  68 +
64 69 /** The history pair. */
65 70 private HashMap<String, HashMap<String, MtasParserObject>> historyPair = new HashMap<>();
66 71  
... ... @@ -96,7 +101,42 @@ public class MtasCRMParser extends MtasBasicParser {
96 101 wordType = new MtasParserType<>(MAPPING_TYPE_WORD, null, false);
97 102 for (int i = 0; i < config.children.size(); i++) {
98 103 MtasConfiguration current = config.children.get(i);
99   - if (current.name.equals("mappings")) {
  104 + if (current.name.equals("filters")) {
  105 + for (int j = 0; j < current.children.size(); j++) {
  106 + if (current.children.get(j).name.equals("filter")) {
  107 + MtasConfiguration filter = current.children.get(j);
  108 + String typeFilter = filter.attributes.get("type");
  109 + String nameFilter = filter.attributes.get("name");
  110 + if(typeFilter!=null) {
  111 + if(typeFilter.equals(FILTER_TYPE_REPLACE)) {
  112 + String value = filter.attributes.get("value");
  113 + String replace = filter.attributes.get("replace");
  114 + if(nameFilter!=null && value!=null && replace!=null) {
  115 + String[] names = nameFilter.split(Pattern.quote(","));
  116 + for(String name : names) {
  117 + HashMap<String, String> nameMap;
  118 + if(!filterReplace.containsKey(name)) {
  119 + nameMap = new HashMap<>();
  120 + filterReplace.put(Integer.parseInt(name), nameMap);
  121 + } else {
  122 + nameMap = filterReplace.get(name);
  123 + }
  124 + nameMap.put(value, replace);
  125 + }
  126 + } else {
  127 + throw new MtasConfigException("no name, value or replace for filter "
  128 + + typeFilter );
  129 + }
  130 + } else {
  131 + throw new MtasConfigException("unknown filter type "
  132 + + typeFilter );
  133 + }
  134 + } else {
  135 + throw new MtasConfigException("no type provided for filter" );
  136 + }
  137 + }
  138 + }
  139 + } else if (current.name.equals("mappings")) {
100 140 for (int j = 0; j < current.children.size(); j++) {
101 141 if (current.children.get(j).name.equals("mapping")) {
102 142 MtasConfiguration mapping = current.children.get(j);
... ... @@ -256,18 +296,20 @@ public class MtasCRMParser extends MtasBasicParser {
256 296 Set<MtasParserObject> newPreviousSentence = new HashSet<>();
257 297 Set<MtasParserObject> previousSentence = new HashSet<>();
258 298 Set<MtasParserObject> newPreviousClause = new HashSet<>();
259   - Set<MtasParserObject> previousClause = new HashSet<>();
  299 + Set<MtasParserObject> previousClause = new HashSet<>();
  300 + String[] matcherList = new String[8];
260 301 while ((line = br.readLine()) != null) {
261 302 currentOffset = br.getPosition();
262 303 matcherHeader = headerPattern.matcher(line.trim());
263 304 matcherRegular = regularPattern.matcher(line.trim());
264 305 if (matcherRegular.matches()) {
265 306 newPreviousSentence.clear();
  307 + matcherList = createMatcherList(matcherRegular);
266 308 for (int i = 4; i < 8; i++) {
267 309 List<MtasCRMParserFunctionOutput> functionOutputList = new ArrayList<>();
268 310 Set<MtasParserObject> tmpList = processCRMSentence(
269 311 mtasTokenIdFactory, String.valueOf(i),
270   - matcherRegular.group((i + 1)), currentOffset,
  312 + matcherList[i], currentOffset,
271 313 functionOutputList, unknownAncestors, currentList, updateList,
272 314 idPositions, idOffsets, previousSentence, previousClause);
273 315 if (tmpList != null) {
... ... @@ -291,7 +333,7 @@ public class MtasCRMParser extends MtasBasicParser {
291 333 for (int i = 4; i < 8; i++) {
292 334 ArrayList<MtasCRMParserFunctionOutput> functionOutputList = new ArrayList<>();
293 335 Set<MtasParserObject> tmpList = processCRMClause(mtasTokenIdFactory,
294   - String.valueOf(i), matcherRegular.group((i + 1)), currentOffset,
  336 + String.valueOf(i), matcherList[i], currentOffset,
295 337 functionOutputList, unknownAncestors, currentList, updateList,
296 338 idPositions, idOffsets, previousClause);
297 339 if (tmpList != null) {
... ... @@ -333,7 +375,7 @@ public class MtasCRMParser extends MtasBasicParser {
333 375 for (int i = 0; i < 8; i++) {
334 376 List<MtasCRMParserFunctionOutput> functionOutputList = new ArrayList<>();
335 377 processCRMPair(mtasTokenIdFactory, p, String.valueOf(i),
336   - matcherRegular.group((i + 1)), currentOffset,
  378 + matcherList[i], currentOffset,
337 379 functionOutputList, unknownAncestors, currentList,
338 380 updateList, idPositions, idOffsets);
339 381 for (MtasCRMParserFunctionOutput functionOutput : functionOutputList) {
... ... @@ -348,7 +390,7 @@ public class MtasCRMParser extends MtasBasicParser {
348 390 ArrayList<MtasCRMParserFunctionOutput> functionOutputList = new ArrayList<>();
349 391 functionOutputList
350 392 .addAll(processWordAnnotation(mtasTokenIdFactory,
351   - String.valueOf(i), matcherRegular.group((i + 1)),
  393 + String.valueOf(i), matcherList[i],
352 394 previousOffset, currentOffset, unknownAncestors,
353 395 currentList, updateList, idPositions, idOffsets));
354 396 for (MtasCRMParserFunctionOutput functionOutput : functionOutputList) {
... ... @@ -407,6 +449,21 @@ public class MtasCRMParser extends MtasBasicParser {
407 449  
408 450 }
409 451  
  452 + private String[] createMatcherList(Matcher matcher) {
  453 + String[] list = new String[8];
  454 + String value;
  455 + for(int i=0; i<8; i++) {
  456 + value = matcher.group((i+1));
  457 + if(filterReplace.containsKey(i)) {
  458 + for(Entry<String,String> entry : filterReplace.get(i).entrySet()) {
  459 + value = value.replaceAll(Pattern.quote(entry.getKey()), entry.getValue());
  460 + }
  461 + }
  462 + list[i] = value;
  463 + }
  464 + return list;
  465 + }
  466 +
410 467 /**
411 468 * Process word annotation.
412 469 *
... ...
src/main/java/mtas/analysis/util/MtasBufferedReader.java
... ... @@ -265,6 +265,44 @@ public class MtasBufferedReader extends Reader {
265 265 }
266 266  
267 267 /**
  268 + * Lines.
  269 + *
  270 + * @return the stream
  271 + */
  272 + public Stream<String> lines() {
  273 + Iterator<String> iter = new Iterator<String>() {
  274 + String nextLine = null;
  275 +
  276 + @Override
  277 + public boolean hasNext() {
  278 + if (nextLine != null) {
  279 + return true;
  280 + } else {
  281 + try {
  282 + nextLine = readLine();
  283 + return (nextLine != null);
  284 + } catch (IOException e) {
  285 + throw new UncheckedIOException(e);
  286 + }
  287 + }
  288 + }
  289 +
  290 + @Override
  291 + public String next() {
  292 + if (nextLine != null || hasNext()) {
  293 + String line = nextLine;
  294 + nextLine = null;
  295 + return line;
  296 + } else {
  297 + throw new NoSuchElementException();
  298 + }
  299 + }
  300 + };
  301 + return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter,
  302 + Spliterator.ORDERED | Spliterator.NONNULL), false);
  303 + }
  304 +
  305 + /**
268 306 * Gets the position.
269 307 *
270 308 * @return the position
... ... @@ -375,42 +413,4 @@ public class MtasBufferedReader extends Reader {
375 413 }
376 414 }
377 415 }
378   -
379   - /**
380   - * Lines.
381   - *
382   - * @return the stream
383   - */
384   - public Stream<String> lines() {
385   - Iterator<String> iter = new Iterator<String>() {
386   - String nextLine = null;
387   -
388   - @Override
389   - public boolean hasNext() {
390   - if (nextLine != null) {
391   - return true;
392   - } else {
393   - try {
394   - nextLine = readLine();
395   - return (nextLine != null);
396   - } catch (IOException e) {
397   - throw new UncheckedIOException(e);
398   - }
399   - }
400   - }
401   -
402   - @Override
403   - public String next() {
404   - if (nextLine != null || hasNext()) {
405   - String line = nextLine;
406   - nextLine = null;
407   - return line;
408   - } else {
409   - throw new NoSuchElementException();
410   - }
411   - }
412   - };
413   - return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter,
414   - Spliterator.ORDERED | Spliterator.NONNULL), false);
415   - }
416 416 }
... ...
src/main/java/mtas/codec/util/CodecCollector.java
... ... @@ -105,33 +105,60 @@ public class CodecCollector {
105 105 /**
106 106 * Collect field.
107 107 *
108   - * @param field the field
109   - * @param searcher the searcher
110   - * @param reader the reader
111   - * @param rawReader the raw reader
112   - * @param fullDocList the full doc list
113   - * @param fullDocSet the full doc set
114   - * @param fieldInfo the field info
115   - * @param spansQueryWeight the spans query weight
116   - * @throws IllegalAccessException the illegal access exception
117   - * @throws IllegalArgumentException the illegal argument exception
118   - * @throws InvocationTargetException the invocation target exception
119   - * @throws IOException Signals that an I/O exception has occurred.
  108 + * @param field
  109 + * the field
  110 + * @param searcher
  111 + * the searcher
  112 + * @param reader
  113 + * the reader
  114 + * @param rawReader
  115 + * the raw reader
  116 + * @param fullDocList
  117 + * the full doc list
  118 + * @param fullDocSet
  119 + * the full doc set
  120 + * @param fieldInfo
  121 + * the field info
  122 + * @param spansQueryWeight
  123 + * the spans query weight
  124 + * @throws IllegalAccessException
  125 + * the illegal access exception
  126 + * @throws IllegalArgumentException
  127 + * the illegal argument exception
  128 + * @throws InvocationTargetException
  129 + * the invocation target exception
  130 + * @throws IOException
  131 + * Signals that an I/O exception has occurred.
120 132 */
121 133 public static void collectField(String field, IndexSearcher searcher,
122 134 IndexReader reader, IndexReader rawReader, List<Integer> fullDocList,
123 135 List<Integer> fullDocSet, ComponentField fieldInfo,
124   - Map<MtasSpanQuery, SpanWeight> spansQueryWeight)
  136 + Map<MtasSpanQuery, SpanWeight> spansQueryWeight, Status status)
125 137 throws IllegalAccessException, IllegalArgumentException,
126 138 InvocationTargetException, IOException {
127 139  
128 140 Map<Integer, List<Integer>> docSets = new HashMap<>();
129 141  
130 142 ListIterator<LeafReaderContext> iterator = reader.leaves().listIterator();
  143 + long numberOfDocumentsFound = 0;
  144 + if (status != null) {
  145 + status.init(reader.numDocs(), reader.leaves().size());
  146 + if (fullDocSet != null && status.numberDocumentsFound == null) {
  147 + status.numberDocumentsFound = numberOfDocumentsFound;
  148 + }
  149 + }
  150 +
131 151 while (iterator.hasNext()) {
  152 + // try
  153 + // {
  154 + // Thread.sleep(10000);
  155 + // }
  156 + // catch(InterruptedException ex)
  157 + // {
  158 + // Thread.currentThread().interrupt();
  159 + // }
132 160 LeafReaderContext lrc = iterator.next();
133 161 LeafReader r = lrc.reader();
134   -
135 162 // compute relevant docSet/docList
136 163 List<Integer> docSet = null;
137 164 List<Integer> docList = null;
... ... @@ -151,6 +178,9 @@ public class CodecCollector {
151 178 }
152 179 }
153 180 Collections.sort(docSet);
  181 + numberOfDocumentsFound += docSet.size();
  182 + status.numberDocumentsFound = Math.max(status.numberDocumentsFound,
  183 + numberOfDocumentsFound);
154 184 }
155 185 if (fullDocList != null) {
156 186 docList = new ArrayList<>();
... ... @@ -172,9 +202,29 @@ public class CodecCollector {
172 202  
173 203 collectSpansPositionsAndTokens(spansQueryWeight, searcher, mtasCodecInfo,
174 204 r, lrc, field, t, docSet, docList, fieldInfo,
175   - rawReader.leaves().get(lrc.ord).reader().getFieldInfos());
  205 + rawReader.leaves().get(lrc.ord).reader().getFieldInfos(), status);
176 206 collectPrefixes(rawReader.leaves().get(lrc.ord).reader().getFieldInfos(),
177   - field, fieldInfo);
  207 + field, fieldInfo, status);
  208 +
  209 + if (status != null) {
  210 + Integer segmentNumber;
  211 + Long documentNumber;
  212 + if ((segmentNumber = status.subNumberSegmentsFinished
  213 + .get(field)) != null) {
  214 + status.subNumberSegmentsFinished.put(field, segmentNumber + 1);
  215 + status.subNumberSegmentsFinishedTotal++;
  216 + status.numberSegmentsFinished = Collections
  217 + .max(status.subNumberSegmentsFinished.values());
  218 + }
  219 + if ((documentNumber = status.subNumberDocumentsFinished
  220 + .get(field)) != null) {
  221 + status.subNumberDocumentsFinished.put(field,
  222 + documentNumber + r.numDocs());
  223 + status.subNumberDocumentsFinishedTotal += +r.numDocs();
  224 + status.numberDocumentsFinished = Collections
  225 + .max(status.subNumberDocumentsFinished.values());
  226 + }
  227 + }
178 228 }
179 229  
180 230 // check termvectors
... ... @@ -206,18 +256,23 @@ public class CodecCollector {
206 256 docSet);
207 257 }
208 258 createTermvectorSecondRound(fieldInfo.termVectorList, positionsData,
209   - docSets.get(lrc.ord), t, r, lrc);
  259 + docSets.get(lrc.ord), t, r, lrc, status);
210 260 }
  261 +
211 262 }
212 263 }
213 264  
214 265 /**
215 266 * Collect collection.
216 267 *
217   - * @param reader the reader
218   - * @param docSet the doc set
219   - * @param collectionInfo the collection info
220   - * @throws IOException Signals that an I/O exception has occurred.
  268 + * @param reader
  269 + * the reader
  270 + * @param docSet
  271 + * the doc set
  272 + * @param collectionInfo
  273 + * the collection info
  274 + * @throws IOException
  275 + * Signals that an I/O exception has occurred.
221 276 */
222 277 public static void collectCollection(IndexReader reader, List<Integer> docSet,
223 278 ComponentCollection collectionInfo) throws IOException {
... ... @@ -269,24 +324,37 @@ public class CodecCollector {
269 324 /**
270 325 * Collect spans positions and tokens.
271 326 *
272   - * @param spansQueryWeight the spans query weight
273   - * @param searcher the searcher
274   - * @param mtasCodecInfo the mtas codec info
275   - * @param r the r
276   - * @param lrc the lrc
277   - * @param field the field
278   - * @param t the t
279   - * @param docSet the doc set
280   - * @param docList the doc list
281   - * @param fieldInfo the field info
282   - * @param fieldInfos the field infos
283   - * @throws IOException Signals that an I/O exception has occurred.
  327 + * @param spansQueryWeight
  328 + * the spans query weight
  329 + * @param searcher
  330 + * the searcher
  331 + * @param mtasCodecInfo
  332 + * the mtas codec info
  333 + * @param r
  334 + * the r
  335 + * @param lrc
  336 + * the lrc
  337 + * @param field
  338 + * the field
  339 + * @param t
  340 + * the t
  341 + * @param docSet
  342 + * the doc set
  343 + * @param docList
  344 + * the doc list
  345 + * @param fieldInfo
  346 + * the field info
  347 + * @param fieldInfos
  348 + * the field infos
  349 + * @throws IOException
  350 + * Signals that an I/O exception has occurred.
284 351 */
285 352 private static void collectSpansPositionsAndTokens(
286 353 Map<MtasSpanQuery, SpanWeight> spansQueryWeight, IndexSearcher searcher,
287 354 CodecInfo mtasCodecInfo, LeafReader r, LeafReaderContext lrc,
288 355 String field, Terms t, List<Integer> docSet, List<Integer> docList,
289   - ComponentField fieldInfo, FieldInfos fieldInfos) throws IOException {
  356 + ComponentField fieldInfo, FieldInfos fieldInfos, Status status)
  357 + throws IOException {
290 358  
291 359 boolean needSpans = false;
292 360 boolean needPositions = false;
... ... @@ -463,7 +531,7 @@ public class CodecCollector {
463 531 if (docValues.advanceExact(docId)) {
464 532 long value = docValues.longValue();
465 533 if (!facetDataSubList.containsKey(value)) {
466   - List<Integer> facetDataSubListItem = new ArrayList<Integer>();
  534 + List<Integer> facetDataSubListItem = new ArrayList<>();
467 535 facetDataSubListItem.add(docId + lrc.docBase);
468 536 facetDataSubList.put(value, facetDataSubListItem);
469 537 } else {
... ... @@ -750,7 +818,7 @@ public class CodecCollector {
750 818 // create group
751 819 createGroup(fieldInfo.groupList, spansMatchData, docSet,
752 820 fieldInfos.fieldInfo(field), field, lrc.docBase, mtasCodecInfo,
753   - searcher, lrc);
  821 + searcher, lrc, status);
754 822 }
755 823 if (!fieldInfo.kwicList.isEmpty()) {
756 824 // create kwic
... ... @@ -774,9 +842,11 @@ public class CodecCollector {
774 842 /**
775 843 * Collect known prefixes.
776 844 *
777   - * @param fi the fi
  845 + * @param fi
  846 + * the fi
778 847 * @return the sets the
779   - * @throws IOException Signals that an I/O exception has occurred.
  848 + * @throws IOException
  849 + * Signals that an I/O exception has occurred.
780 850 */
781 851 private static Set<String> collectKnownPrefixes(FieldInfo fi)
782 852 throws IOException {
... ... @@ -827,9 +897,11 @@ public class CodecCollector {
827 897 /**
828 898 * Collect intersection prefixes.
829 899 *
830   - * @param fi the fi
  900 + * @param fi
  901 + * the fi
831 902 * @return the sets the
832   - * @throws IOException Signals that an I/O exception has occurred.
  903 + * @throws IOException
  904 + * Signals that an I/O exception has occurred.
833 905 */
834 906 private static Set<String> collectIntersectionPrefixes(FieldInfo fi)
835 907 throws IOException {
... ... @@ -856,13 +928,17 @@ public class CodecCollector {
856 928 /**
857 929 * Collect prefixes.
858 930 *
859   - * @param fieldInfos the field infos
860   - * @param field the field
861   - * @param fieldInfo the field info
862   - * @throws IOException Signals that an I/O exception has occurred.
  931 + * @param fieldInfos
  932 + * the field infos
  933 + * @param field
  934 + * the field
  935 + * @param fieldInfo
  936 + * the field info
  937 + * @throws IOException
  938 + * Signals that an I/O exception has occurred.
863 939 */
864 940 private static void collectPrefixes(FieldInfos fieldInfos, String field,
865   - ComponentField fieldInfo) throws IOException {
  941 + ComponentField fieldInfo, Status status) throws IOException {
866 942 if (fieldInfo.prefix != null) {
867 943 FieldInfo fi = fieldInfos.fieldInfo(field);
868 944 if (fi != null) {
... ... @@ -909,13 +985,19 @@ public class CodecCollector {
909 985 /**
910 986 * Collect spans for occurences.
911 987 *
912   - * @param occurences the occurences
913   - * @param prefixes the prefixes
914   - * @param field the field
915   - * @param searcher the searcher
916   - * @param lrc the lrc
  988 + * @param occurences
  989 + * the occurences
  990 + * @param prefixes
  991 + * the prefixes
  992 + * @param field
  993 + * the field
  994 + * @param searcher
  995 + * the searcher
  996 + * @param lrc
  997 + * the lrc
917 998 * @return the map
918   - * @throws IOException Signals that an I/O exception has occurred.
  999 + * @throws IOException
  1000 + * Signals that an I/O exception has occurred.
919 1001 */
920 1002 private static Map<GroupHit, Spans> collectSpansForOccurences(
921 1003 Set<GroupHit> occurences, Set<String> prefixes, String field,
... ... @@ -941,9 +1023,12 @@ public class CodecCollector {
941 1023 /**
942 1024 * Creates the query from group hit.
943 1025 *
944   - * @param prefixes the prefixes
945   - * @param field the field
946   - * @param hit the hit
  1026 + * @param prefixes
  1027 + * the prefixes
  1028 + * @param field
  1029 + * the field
  1030 + * @param hit
  1031 + * the hit
947 1032 * @return the mtas span query
948 1033 */
949 1034 private static MtasSpanQuery createQueryFromGroupHit(Set<String> prefixes,
... ... @@ -997,9 +1082,12 @@ public class CodecCollector {
997 1082 /**
998 1083 * Creates the sub query from group hit.
999 1084 *
1000   - * @param subHit the sub hit
1001   - * @param reverse the reverse
1002   - * @param field the field
  1085 + * @param subHit
  1086 + * the sub hit
  1087 + * @param reverse
  1088 + * the reverse
  1089 + * @param field
  1090 + * the field
1003 1091 * @return the mtas span query
1004 1092 */
1005 1093 private static MtasSpanQuery createSubQueryFromGroupHit(List<String>[] subHit,
... ... @@ -1038,13 +1126,19 @@ public class CodecCollector {
1038 1126 /**
1039 1127 * Compute positions.
1040 1128 *
1041   - * @param mtasCodecInfo the mtas codec info
1042   - * @param r the r
1043   - * @param lrc the lrc
1044   - * @param field the field
1045   - * @param docSet the doc set
  1129 + * @param mtasCodecInfo
  1130 + * the mtas codec info
  1131 + * @param r
  1132 + * the r
  1133 + * @param lrc
  1134 + * the lrc
  1135 + * @param field
  1136 + * the field
  1137 + * @param docSet
  1138 + * the doc set
1046 1139 * @return the map
1047   - * @throws IOException Signals that an I/O exception has occurred.
  1140 + * @throws IOException
  1141 + * Signals that an I/O exception has occurred.
1048 1142 */
1049 1143 private static Map<Integer, Integer> computePositions(CodecInfo mtasCodecInfo,
1050 1144 LeafReader r, LeafReaderContext lrc, String field, List<Integer> docSet)
... ... @@ -1080,9 +1174,12 @@ public class CodecCollector {
1080 1174 /**
1081 1175 * Compute arguments.
1082 1176 *
1083   - * @param spansNumberData the spans number data
1084   - * @param queries the queries
1085   - * @param docSet the doc set
  1177 + * @param spansNumberData
  1178 + * the spans number data
  1179 + * @param queries
  1180 + * the queries
  1181 + * @param docSet
  1182 + * the doc set
1086 1183 * @return the map
1087 1184 */
1088 1185 private static Map<Integer, long[]> computeArguments(
... ... @@ -1113,8 +1210,10 @@ public class CodecCollector {
1113 1210 /**
1114 1211 * Intersected doc list.
1115 1212 *
1116   - * @param facetDocList the facet doc list
1117   - * @param docSet the doc set
  1213 + * @param facetDocList
  1214 + * the facet doc list
  1215 + * @param docSet
  1216 + * the doc set
1118 1217 * @return the integer[]
1119 1218 */
1120 1219 private static Integer[] intersectedDocList(int[] facetDocList,
... ... @@ -1145,10 +1244,14 @@ public class CodecCollector {
1145 1244 /**
1146 1245 * Creates the positions.
1147 1246 *
1148   - * @param statsPositionList the stats position list
1149   - * @param positionsData the positions data
1150   - * @param docSet the doc set
1151   - * @throws IOException Signals that an I/O exception has occurred.
  1247 + * @param statsPositionList
  1248 + * the stats position list
  1249 + * @param positionsData
  1250 + * the positions data
  1251 + * @param docSet
  1252 + * the doc set
  1253 + * @throws IOException
  1254 + * Signals that an I/O exception has occurred.
1152 1255 */
1153 1256 private static void createPositions(List<ComponentPosition> statsPositionList,
1154 1257 Map<Integer, Integer> positionsData, List<Integer> docSet)
... ... @@ -1182,10 +1285,14 @@ public class CodecCollector {
1182 1285 /**
1183 1286 * Creates the tokens.
1184 1287 *
1185   - * @param statsTokenList the stats token list
1186   - * @param tokensData the tokens data
1187   - * @param docSet the doc set
1188   - * @throws IOException Signals that an I/O exception has occurred.
  1288 + * @param statsTokenList
  1289 + * the stats token list
  1290 + * @param tokensData
  1291 + * the tokens data
  1292 + * @param docSet
  1293 + * the doc set
  1294 + * @throws IOException
  1295 + * Signals that an I/O exception has occurred.
1189 1296 */
1190 1297 private static void createTokens(List<ComponentToken> statsTokenList,
1191 1298 Map<Integer, Integer> tokensData, List<Integer> docSet)
... ... @@ -1220,11 +1327,16 @@ public class CodecCollector {
1220 1327 /**
1221 1328 * Creates the stats.
1222 1329 *
1223   - * @param statsSpanList the stats span list
1224   - * @param positionsData the positions data
1225   - * @param spansNumberData the spans number data
1226   - * @param docSet the doc set
1227   - * @throws IOException Signals that an I/O exception has occurred.
  1330 + * @param statsSpanList
  1331 + * the stats span list
  1332 + * @param positionsData
  1333 + * the positions data
  1334 + * @param spansNumberData
  1335 + * the spans number data
  1336 + * @param docSet
  1337 + * the doc set
  1338 + * @throws IOException
  1339 + * Signals that an I/O exception has occurred.
1228 1340 */
1229 1341 private static void createStats(List<ComponentSpan> statsSpanList,
1230 1342 Map<Integer, Integer> positionsData,
... ... @@ -1402,16 +1514,26 @@ public class CodecCollector {
1402 1514 /**
1403 1515 * Creates the list.
1404 1516 *
1405   - * @param listList the list list
1406   - * @param spansNumberData the spans number data
1407   - * @param spansMatchData the spans match data
1408   - * @param docSet the doc set
1409   - * @param field the field
1410   - * @param docBase the doc base
1411   - * @param uniqueKeyField the unique key field
1412   - * @param mtasCodecInfo the mtas codec info
1413   - * @param searcher the searcher
1414   - * @throws IOException Signals that an I/O exception has occurred.
  1517 + * @param listList
  1518 + * the list list
  1519 + * @param spansNumberData
  1520 + * the spans number data
  1521 + * @param spansMatchData
  1522 + * the spans match data
  1523 + * @param docSet
  1524 + * the doc set
  1525 + * @param field
  1526 + * the field
  1527 + * @param docBase
  1528 + * the doc base
  1529 + * @param uniqueKeyField
  1530 + * the unique key field
  1531 + * @param mtasCodecInfo
  1532 + * the mtas codec info
  1533 + * @param searcher
  1534 + * the searcher
  1535 + * @throws IOException
  1536 + * Signals that an I/O exception has occurred.
1415 1537 */
1416 1538 private static void createList(List<ComponentList> listList,
1417 1539 Map<MtasSpanQuery, Map<Integer, Integer>> spansNumberData,
... ... @@ -1566,22 +1688,32 @@ public class CodecCollector {
1566 1688 /**
1567 1689 * Creates the group.
1568 1690 *
1569   - * @param groupList the group list
1570   - * @param spansMatchData the spans match data
1571   - * @param docSet the doc set
1572   - * @param fieldInfo the field info
1573   - * @param field the field
1574   - * @param docBase the doc base
1575   - * @param mtasCodecInfo the mtas codec info
1576   - * @param searcher the searcher
1577   - * @param lrc the lrc
1578   - * @throws IOException Signals that an I/O exception has occurred.
  1691 + * @param groupList
  1692 + * the group list
  1693 + * @param spansMatchData
  1694 + * the spans match data
  1695 + * @param docSet
  1696 + * the doc set
  1697 + * @param fieldInfo
  1698 + * the field info
  1699 + * @param field
  1700 + * the field
  1701 + * @param docBase
  1702 + * the doc base
  1703 + * @param mtasCodecInfo
  1704 + * the mtas codec info
  1705 + * @param searcher
  1706 + * the searcher
  1707 + * @param lrc
  1708 + * the lrc
  1709 + * @throws IOException
  1710 + * Signals that an I/O exception has occurred.
1579 1711 */
1580 1712 private static void createGroup(List<ComponentGroup> groupList,
1581 1713 Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData,
1582 1714 List<Integer> docSet, FieldInfo fieldInfo, String field, int docBase,
1583   - CodecInfo mtasCodecInfo, IndexSearcher searcher, LeafReaderContext lrc)
1584   - throws IOException {
  1715 + CodecInfo mtasCodecInfo, IndexSearcher searcher, LeafReaderContext lrc,
  1716 + Status status) throws IOException {
1585 1717  
1586 1718 if (mtasCodecInfo != null && groupList != null) {
1587 1719 List<Match> matchList;
... ... @@ -1752,8 +1884,10 @@ public class CodecCollector {
1752 1884 /**
1753 1885 * Available prefixes.
1754 1886 *
1755   - * @param group the group
1756   - * @param knownPrefixes the known prefixes
  1887 + * @param group
  1888 + * the group
  1889 + * @param knownPrefixes
  1890 + * the known prefixes
1757 1891 * @return true, if successful
1758 1892 */
1759 1893 private static boolean availablePrefixes(ComponentGroup group,
... ... @@ -1771,8 +1905,10 @@ public class CodecCollector {
1771 1905 /**
1772 1906 * Intersection prefixes.
1773 1907 *
1774   - * @param group the group
1775   - * @param intersectionPrefixes the intersection prefixes
  1908 + * @param group
  1909 + * the group
  1910 + * @param intersectionPrefixes
  1911 + * the intersection prefixes
1776 1912 * @return true, if successful
1777 1913 */
1778 1914 private static boolean intersectionPrefixes(ComponentGroup group,
... ... @@ -1790,8 +1926,10 @@ public class CodecCollector {
1790 1926 /**
1791 1927 * Creates the position hit.
1792 1928 *
1793   - * @param m the m
1794   - * @param group the group
  1929 + * @param m
  1930 + * the m
  1931 + * @param group
  1932 + * the group
1795 1933 * @return the interval tree node data
1796 1934 */
1797 1935 private static IntervalTreeNodeData<String> createPositionHit(Match m,
... ... @@ -1834,15 +1972,23 @@ public class CodecCollector {
1834 1972 /**
1835 1973 * Collect group using spans.
1836 1974 *
1837   - * @param list the list
1838   - * @param docSet the doc set
1839   - * @param docBase the doc base
1840   - * @param docCounter the doc counter
1841   - * @param matchData the match data
1842   - * @param occurencesSum the occurences sum
1843   - * @param occurencesN the occurences N
  1975 + * @param list
  1976 + * the list
  1977 + * @param docSet
  1978 + * the doc set
  1979 + * @param docBase
  1980 + * the doc base
  1981 + * @param docCounter
  1982 + * the doc counter
  1983 + * @param matchData
  1984 + * the match data
  1985 + * @param occurencesSum
  1986 + * the occurences sum
  1987 + * @param occurencesN
  1988 + * the occurences N
1844 1989 * @return the int
1845   - * @throws IOException Signals that an I/O exception has occurred.
  1990 + * @throws IOException
  1991 + * Signals that an I/O exception has occurred.
1846 1992 */
1847 1993 private static int collectGroupUsingSpans(Map<GroupHit, Spans> list,
1848 1994 List<Integer> docSet, int docBase, int docCounter,
... ... @@ -2040,7 +2186,8 @@ public class CodecCollector {
2040 2186 /**
2041 2187 * Sort match list.
2042 2188 *
2043   - * @param list the list
  2189 + * @param list
  2190 + * the list
2044 2191 */
2045 2192 private static void sortMatchList(List<Match> list) {
2046 2193 if (list != null) {
... ... @@ -2053,13 +2200,20 @@ public class CodecCollector {
2053 2200 /**
2054 2201 * Creates the document.
2055 2202 *
2056   - * @param documentList the document list
2057   - * @param docList the doc list
2058   - * @param uniqueKeyField the unique key field
2059   - * @param searcher the searcher
2060   - * @param t the t
2061   - * @param lrc the lrc
2062   - * @throws IOException Signals that an I/O exception has occurred.
  2203 + * @param documentList
  2204 + * the document list
  2205 + * @param docList
  2206 + * the doc list
  2207 + * @param uniqueKeyField
  2208 + * the unique key field
  2209 + * @param searcher
  2210 + * the searcher
  2211 + * @param t
  2212 + * the t
  2213 + * @param lrc
  2214 + * the lrc
  2215 + * @throws IOException
  2216 + * Signals that an I/O exception has occurred.
2063 2217 */
2064 2218 private static void createDocument(List<ComponentDocument> documentList,
2065 2219 List<Integer> docList, String uniqueKeyField, IndexSearcher searcher,
... ... @@ -2266,15 +2420,24 @@ public class CodecCollector {
2266 2420 /**
2267 2421 * Creates the kwic.
2268 2422 *
2269   - * @param kwicList the kwic list
2270   - * @param spansMatchData the spans match data
2271   - * @param docList the doc list
2272   - * @param field the field
2273   - * @param docBase the doc base
2274   - * @param uniqueKeyField the unique key field
2275   - * @param mtasCodecInfo the mtas codec info
2276   - * @param searcher the searcher
2277   - * @throws IOException Signals that an I/O exception has occurred.
  2423 + * @param kwicList
  2424 + * the kwic list
  2425 + * @param spansMatchData
  2426 + * the spans match data
  2427 + * @param docList
  2428 + * the doc list
  2429 + * @param field
  2430 + * the field
  2431 + * @param docBase
  2432 + * the doc base
  2433 + * @param uniqueKeyField
  2434 + * the unique key field
  2435 + * @param mtasCodecInfo
  2436 + * the mtas codec info
  2437 + * @param searcher
  2438 + * the searcher
  2439 + * @throws IOException
  2440 + * Signals that an I/O exception has occurred.
2278 2441 */
2279 2442 private static void createKwic(List<ComponentKwic> kwicList,
2280 2443 Map<MtasSpanQuery, Map<Integer, List<Match>>> spansMatchData,
... ... @@ -2391,14 +2554,22 @@ public class CodecCollector {
2391 2554 /**
2392 2555 * Creates the facet base.
2393 2556 *
2394   - * @param cf the cf
2395   - * @param level the level
2396   - * @param dataCollector the data collector
2397   - * @param positionsData the positions data
2398   - * @param spansNumberData the spans number data
2399   - * @param facetData the facet data
2400   - * @param docSet the doc set
2401   - * @throws IOException Signals that an I/O exception has occurred.
  2557 + * @param cf
  2558 + * the cf
  2559 + * @param level
  2560 + * the level
  2561 + * @param dataCollector
  2562 + * the data collector
  2563 + * @param positionsData
  2564 + * the positions data
  2565 + * @param spansNumberData
  2566 + * the spans number data
  2567 + * @param facetData
  2568 + * the facet data
  2569 + * @param docSet
  2570 + * the doc set
  2571 + * @throws IOException
  2572 + * Signals that an I/O exception has occurred.
2402 2573 */
2403 2574 private static void createFacetBase(ComponentFacet cf, int level,
2404 2575 MtasDataCollector<?, ?> dataCollector,
... ... @@ -2699,9 +2870,12 @@ public class CodecCollector {
2699 2870 /**
2700 2871 * Grouped key name.
2701 2872 *
2702   - * @param key the key
2703   - * @param baseRangeSize the base range size
2704   - * @param baseRangeBase the base range base
  2873 + * @param key
  2874 + * the key
  2875 + * @param baseRangeSize
  2876 + * the base range size
  2877 + * @param baseRangeBase
  2878 + * the base range base
2705 2879 * @return the string
2706 2880 */
2707 2881 private static String groupedKeyName(String key, Double baseRangeSize,
... ... @@ -2746,8 +2920,10 @@ public class CodecCollector {
2746 2920 /**
2747 2921 * Merge doc lists.
2748 2922 *
2749   - * @param a the a
2750   - * @param b the b
  2923 + * @param a
  2924 + * the a
  2925 + * @param b
  2926 + * the b
2751 2927 * @return the integer[]
2752 2928 */
2753 2929 private static Integer[] mergeDocLists(Integer[] a, Integer[] b) {
... ... @@ -2782,12 +2958,18 @@ public class CodecCollector {
2782 2958 /**
2783 2959 * Creates the facet.
2784 2960 *
2785   - * @param facetList the facet list
2786   - * @param positionsData the positions data
2787   - * @param spansNumberData the spans number data
2788   - * @param facetData the facet data
2789   - * @param docSet the doc set
2790   - * @throws IOException Signals that an I/O exception has occurred.
  2961 + * @param facetList
  2962 + * the facet list
  2963 + * @param positionsData
  2964 + * the positions data
  2965 + * @param spansNumberData
  2966 + * the spans number data
  2967 + * @param facetData
  2968 + * the facet data
  2969 + * @param docSet
  2970 + * the doc set
  2971 + * @throws IOException
  2972 + * Signals that an I/O exception has occurred.
2791 2973 */
2792 2974 private static void createFacet(List<ComponentFacet> facetList,
2793 2975 Map<Integer, Integer> positionsData,
... ... @@ -2809,13 +2991,20 @@ public class CodecCollector {
2809 2991 /**
2810 2992 * Creates the termvector full.
2811 2993 *
2812   - * @param termVectorList the term vector list
2813   - * @param positionsData the positions data
2814   - * @param docSet the doc set
2815   - * @param t the t
2816   - * @param r the r
2817   - * @param lrc the lrc
2818   - * @throws IOException Signals that an I/O exception has occurred.
  2994 + * @param termVectorList
  2995 + * the term vector list
  2996 + * @param positionsData
  2997 + * the positions data
  2998 + * @param docSet
  2999 + * the doc set
  3000 + * @param t
  3001 + * the t
  3002 + * @param r
  3003 + * the r
  3004 + * @param lrc
  3005 + * the lrc
  3006 + * @throws IOException
  3007 + * Signals that an I/O exception has occurred.
2819 3008 */
2820 3009 private static void createTermvectorFull(
2821 3010 List<ComponentTermVector> termVectorList,
... ... @@ -3045,13 +3234,20 @@ public class CodecCollector {
3045 3234 /**
3046 3235 * Creates the termvector first round.
3047 3236 *
3048   - * @param termVectorList the term vector list
3049   - * @param positionsData the positions data
3050   - * @param docSet the doc set
3051   - * @param t the t
3052   - * @param r the r
3053   - * @param lrc the lrc
3054   - * @throws IOException Signals that an I/O exception has occurred.
  3237 + * @param termVectorList
  3238 + * the term vector list
  3239 + * @param positionsData
  3240 + * the positions data
  3241 + * @param docSet
  3242 + * the doc set
  3243 + * @param t
  3244 + * the t
  3245 + * @param r
  3246 + * the r
  3247 + * @param lrc
  3248 + * the lrc
  3249 + * @throws IOException
  3250 + * Signals that an I/O exception has occurred.
3055 3251 */
3056 3252 private static void createTermvectorFirstRound(
3057 3253 List<ComponentTermVector> termVectorList,
... ... @@ -3253,18 +3449,25 @@ public class CodecCollector {
3253 3449 /**
3254 3450 * Creates the termvector second round.
3255 3451 *
3256   - * @param termVectorList the term vector list
3257   - * @param positionsData the positions data
3258   - * @param docSet the doc set
3259   - * @param t the t
3260   - * @param r the r
3261   - * @param lrc the lrc
3262   - * @throws IOException Signals that an I/O exception has occurred.
  3452 + * @param termVectorList
  3453 + * the term vector list
  3454 + * @param positionsData
  3455 + * the positions data
  3456 + * @param docSet
  3457 + * the doc set
  3458 + * @param t
  3459 + * the t
  3460 + * @param r
  3461 + * the r
  3462 + * @param lrc
  3463 + * the lrc
  3464 + * @throws IOException
  3465 + * Signals that an I/O exception has occurred.
3263 3466 */
3264 3467 private static void createTermvectorSecondRound(
3265 3468 List<ComponentTermVector> termVectorList,
3266 3469 Map<Integer, Integer> positionsData, List<Integer> docSet, Terms t,
3267   - LeafReader r, LeafReaderContext lrc) throws IOException {
  3470 + LeafReader r, LeafReaderContext lrc, Status status) throws IOException {
3268 3471 if (t != null) {
3269 3472 BytesRef term;
3270 3473 TermsEnum termsEnum;
... ... @@ -3341,8 +3544,10 @@ public class CodecCollector {
3341 3544 /**
3342 3545 * Validate term with start value.
3343 3546 *
3344   - * @param term the term
3345   - * @param termVector the term vector
  3547 + * @param term
  3548 + * the term
  3549 + * @param termVector
  3550 + * the term vector
3346 3551 * @return true, if successful
3347 3552 */
3348 3553 private static boolean validateTermWithStartValue(BytesRef term,
... ... @@ -3381,25 +3586,49 @@ public class CodecCollector {
3381 3586 /**
3382 3587 * Validate term with distance.
3383 3588 *
3384   - * @param term the term
3385   - * @param termVector the term vector
  3589 + * @param term
  3590 + * the term
  3591 + * @param termVector
  3592 + * the term vector
3386 3593 * @return true, if successful
3387   - * @throws IOException Signals that an I/O exception has occurred.
  3594 + * @throws IOException
  3595 + * Signals that an I/O exception has occurred.
3388 3596 */
3389 3597 private static boolean validateTermWithDistance(BytesRef term,
3390 3598 ComponentTermVector termVector) throws IOException {
3391 3599 if (termVector.distances == null || termVector.distances.isEmpty()) {
3392 3600 return true;
3393 3601 } else {
  3602 + // first check maximum for all distances
3394 3603 for (SubComponentDistance item : termVector.distances) {
3395 3604 if (item.maximum == null) {
3396 3605 continue;
3397 3606 } else {
3398   - if (!item.getDistance().validate(term)) {
  3607 + if (!item.getDistance().validateMaximum(term)) {
  3608 + return false;
  3609 + }
  3610 + }
  3611 + }
  3612 + // then check minimum for all distances
  3613 + for (SubComponentDistance item : termVector.distances) {
  3614 + if (item.minimum == null) {
  3615 + continue;
  3616 + } else {
  3617 + if (!item.getDistance().validateMinimum(term)) {
3399 3618 return false;
3400 3619 }
3401 3620 }
3402 3621 }
  3622 +// try {
  3623 +// System.out.println("ACCEPT: " + term.utf8ToString()+" ("+termVector.distances.size()+")");
  3624 +// for (SubComponentDistance item : termVector.distances) {
  3625 +// System.out.println(
  3626 +// item.hashCode() + "\t" + term.utf8ToString()+"\t"+item.getDistance().getClass().getName()+"\t"+item.getDistance().minimum+"\t"+item.getDistance().maximum
  3627 +// + "\t" + item.getDistance().validate(term)+"\t"+item.getDistance().compute(term));
  3628 +// }
  3629 +// } catch (Exception e) {
  3630 +// System.out.println("PROBLEEM: "+e.getMessage());
  3631 +// }
3403 3632 return true;
3404 3633 }
3405 3634 }
... ... @@ -3407,9 +3636,11 @@ public class CodecCollector {
3407 3636 /**
3408 3637 * Need second round termvector.
3409 3638 *
3410   - * @param termVectorList the term vector list
  3639 + * @param termVectorList
  3640 + * the term vector list
3411 3641 * @return true, if successful
3412   - * @throws IOException Signals that an I/O exception has occurred.
  3642 + * @throws IOException
  3643 + * Signals that an I/O exception has occurred.
3413 3644 */
3414 3645 private static boolean needSecondRoundTermvector(
3415 3646 List<ComponentTermVector> termVectorList) throws IOException {
... ... @@ -3479,7 +3710,8 @@ public class CodecCollector {
3479 3710 /**
3480 3711 * Instantiates a new termvector number full.
3481 3712 *
3482   - * @param maxSize the max size
  3713 + * @param maxSize
  3714 + * the max size
3483 3715 */
3484 3716 TermvectorNumberFull(int maxSize) {
3485 3717 args = new long[maxSize];
... ... @@ -3502,8 +3734,10 @@ public class CodecCollector {
3502 3734 /**
3503 3735 * Instantiates a new register status.
3504 3736 *
3505   - * @param sortValue the sort value
3506   - * @param force the force
  3737 + * @param sortValue
  3738 + * the sort value
  3739 + * @param force
  3740 + * the force
3507 3741 */
3508 3742 RegisterStatus(long sortValue, boolean force) {
3509 3743 this.sortValue = sortValue;
... ... @@ -3514,15 +3748,23 @@ public class CodecCollector {
3514 3748 /**
3515 3749 * Register value.
3516 3750 *
3517   - * @param term the term
3518   - * @param termVector the term vector
3519   - * @param number the number
3520   - * @param termNumberMaximum the term number maximum
3521   - * @param segmentNumber the segment number
3522   - * @param forceAccept the force accept
3523   - * @param mutableKey the mutable key
  3751 + * @param term
  3752 + * the term
  3753 + * @param termVector
  3754 + * the term vector
  3755 + * @param number
  3756 + * the number
  3757 + * @param termNumberMaximum
  3758 + * the term number maximum
  3759 + * @param segmentNumber
  3760 + * the segment number
  3761 + * @param forceAccept
  3762 + * the force accept
  3763 + * @param mutableKey
  3764 + * the mutable key
3524 3765 * @return the register status
3525   - * @throws IOException Signals that an I/O exception has occurred.
  3766 + * @throws IOException
  3767 + * Signals that an I/O exception has occurred.
3526 3768 */
3527 3769 @SuppressWarnings("unchecked")
3528 3770 private static RegisterStatus registerValue(BytesRef term,
... ... @@ -3661,14 +3903,21 @@ public class CodecCollector {
3661 3903 /**
3662 3904 * Preliminary register value.
3663 3905 *
3664   - * @param term the term
3665   - * @param termVector the term vector
3666   - * @param number the number
3667   - * @param termNumberMaximum the term number maximum
3668   - * @param segmentNumber the segment number
3669   - * @param mutableKey the mutable key
  3906 + * @param term
  3907 + * the term
  3908 + * @param termVector
  3909 + * the term vector
  3910 + * @param number
  3911 + * the number
  3912 + * @param termNumberMaximum
  3913 + * the term number maximum
  3914 + * @param segmentNumber
  3915 + * the segment number
  3916 + * @param mutableKey
  3917 + * the mutable key
3670 3918 * @return true, if successful
3671   - * @throws IOException Signals that an I/O exception has occurred.
  3919 + * @throws IOException
  3920 + * Signals that an I/O exception has occurred.
3672 3921 */
3673 3922 private static boolean preliminaryRegisterValue(BytesRef term,
3674 3923 ComponentTermVector termVector, TermvectorNumberBasic number,
... ... @@ -3717,11 +3966,16 @@ public class CodecCollector {
3717 3966 /**
3718 3967 * Register value.
3719 3968 *
3720   - * @param term the term
3721   - * @param termVector the term vector
3722   - * @param number the number
3723   - * @param mutableKey the mutable key
3724   - * @throws IOException Signals that an I/O exception has occurred.
  3969 + * @param term
  3970 + * the term
  3971 + * @param termVector
  3972 + * the term vector
  3973 + * @param number
  3974 + * the number
  3975 + * @param mutableKey
  3976 + * the mutable key
  3977 + * @throws IOException
  3978 + * Signals that an I/O exception has occurred.
3725 3979 */
3726 3980 @SuppressWarnings("unchecked")
3727 3981 private static void registerValue(BytesRef term,
... ... @@ -3785,10 +4039,13 @@ public class CodecCollector {
3785 4039 /**
3786 4040 * Compute termvector number basic.
3787 4041 *
3788   - * @param termsEnum the terms enum
3789   - * @param r the r
  4042 + * @param termsEnum
  4043 + * the terms enum
  4044 + * @param r
  4045 + * the r
3790 4046 * @return the termvector number basic
3791   - * @throws IOException Signals that an I/O exception has occurred.
  4047 + * @throws IOException
  4048 + * Signals that an I/O exception has occurred.
3792 4049 */
3793 4050 private static TermvectorNumberBasic computeTermvectorNumberBasic(
3794 4051 TermsEnum termsEnum, LeafReader r) throws IOException {
... ... @@ -3807,14 +4064,21 @@ public class CodecCollector {
3807 4064 /**
3808 4065 * Compute termvector number basic.
3809 4066 *
3810   - * @param docSet the doc set
3811   - * @param termDocId the term doc id
3812   - * @param termsEnum the terms enum
3813   - * @param r the r
3814   - * @param lrc the lrc
3815   - * @param postingsEnum the postings enum
  4067 + * @param docSet
  4068 + * the doc set
  4069 + * @param termDocId
  4070 + * the term doc id
  4071 + * @param termsEnum
  4072 + * the terms enum
  4073 + * @param r
  4074 + * the r
  4075 + * @param lrc
  4076 + * the lrc
  4077 + * @param postingsEnum
  4078 + * the postings enum
3816 4079 * @return the termvector number basic
3817   - * @throws IOException Signals that an I/O exception has occurred.
  4080 + * @throws IOException
  4081 + * Signals that an I/O exception has occurred.
3818 4082 */
3819 4083 private static TermvectorNumberBasic computeTermvectorNumberBasic(
3820 4084 List<Integer> docSet, int termDocId, TermsEnum termsEnum, LeafReader r,
... ... @@ -3852,14 +4116,21 @@ public class CodecCollector {
3852 4116 /**
3853 4117 * Compute termvector number full.
3854 4118 *
3855   - * @param docSet the doc set
3856   - * @param termDocId the term doc id
3857   - * @param termsEnum the terms enum
3858   - * @param lrc the lrc
3859   - * @param postingsEnum the postings enum
3860   - * @param positionsData the positions data
  4119 + * @param docSet
  4120 + * the doc set
  4121 + * @param termDocId
  4122 + * the term doc id
  4123 + * @param termsEnum
  4124 + * the terms enum
  4125 + * @param lrc
  4126 + * the lrc
  4127 + * @param postingsEnum
  4128 + * the postings enum
  4129 + * @param positionsData
  4130 + * the positions data
3861 4131 * @return the termvector number full
3862   - * @throws IOException Signals that an I/O exception has occurred.
  4132 + * @throws IOException
  4133 + * Signals that an I/O exception has occurred.
3863 4134 */
3864 4135 private static TermvectorNumberFull computeTermvectorNumberFull(
3865 4136 List<Integer> docSet, int termDocId, TermsEnum termsEnum,
... ...
src/main/java/mtas/codec/util/CodecComponent.java
... ... @@ -7,6 +7,8 @@ import java.io.InputStreamReader;
7 7 import java.io.Serializable;
8 8 import java.io.StringReader;
9 9 import java.io.UnsupportedEncodingException;
  10 +import java.lang.reflect.Constructor;
  11 +import java.lang.reflect.InvocationTargetException;
10 12 import java.net.HttpURLConnection;
11 13 import java.net.URL;
12 14 import java.net.URLEncoder;
... ... @@ -22,6 +24,7 @@ import java.util.HashMap;
22 24 import java.util.HashSet;
23 25 import java.util.List;
24 26 import java.util.Map;
  27 +import java.util.Objects;
25 28 import java.util.Set;
26 29 import java.util.SortedSet;
27 30 import java.util.TreeSet;
... ... @@ -32,6 +35,7 @@ import mtas.analysis.token.MtasTokenString;
32 35 import mtas.codec.util.CodecSearchTree.MtasTreeHit;
33 36 import mtas.codec.util.collector.MtasDataCollector;
34 37 import mtas.codec.util.distance.LevenshteinDistance;
  38 +import mtas.codec.util.distance.MorseDistance;
35 39 import mtas.codec.util.distance.DamerauLevenshteinDistance;
36 40 import mtas.codec.util.distance.Distance;
37 41 import mtas.parser.function.MtasFunctionParser;
... ... @@ -49,10 +53,7 @@ import org.noggit.ObjectBuilder;
49 53 /**
50 54 * The Class CodecComponent.
51 55 */
52   -/**
53   - * @author matthijs
54   - *
55   - */
  56 +
56 57 public class CodecComponent {
57 58  
58 59 /**
... ... @@ -66,6 +67,8 @@ public class CodecComponent {
66 67 */
67 68 public static class ComponentFields {
68 69  
  70 + public ComponentStatus status;
  71 +
69 72 /** The list. */
70 73 public Map<String, ComponentField> list;
71 74  
... ... @@ -108,10 +111,14 @@ public class CodecComponent {
108 111 /** The do collection. */
109 112 public boolean doCollection;
110 113  
  114 + /** The do status. */
  115 + public boolean doStatus;
  116 +
111 117 /**
112 118 * Instantiates a new component fields.
113 119 */
114 120 public ComponentFields() {
  121 + status = null;
115 122 list = new HashMap<>();
116 123 collection = new ArrayList<>();
117 124 doDocument = false;
... ... @@ -126,6 +133,7 @@ public class CodecComponent {
126 133 doPrefix = false;
127 134 doFacet = false;
128 135 doCollection = false;
  136 + doStatus = false;
129 137 }
130 138 }
131 139  
... ... @@ -179,7 +187,8 @@ public class CodecComponent {
179 187 /**
180 188 * Instantiates a new component field.
181 189 *
182   - * @param uniqueKeyField the unique key field
  190 + * @param uniqueKeyField
  191 + * the unique key field
183 192 */
184 193 public ComponentField(String uniqueKeyField) {
185 194 this.uniqueKeyField = uniqueKeyField;
... ... @@ -221,7 +230,8 @@ public class CodecComponent {
221 230 /**
222 231 * Instantiates a new component prefix.
223 232 *
224   - * @param key the key
  233 + * @param key
  234 + * the key
225 235 */
226 236 public ComponentPrefix(String key) {
227 237 this.key = key;
... ... @@ -234,7 +244,8 @@ public class CodecComponent {
234 244 /**
235 245 * Adds the single position.
236 246 *
237   - * @param prefix the prefix
  247 + * @param prefix
  248 + * the prefix
238 249 */
239 250 public void addSinglePosition(String prefix) {
240 251 if (!prefix.trim().isEmpty() && !singlePositionList.contains(prefix)
... ... @@ -246,7 +257,8 @@ public class CodecComponent {
246 257 /**
247 258 * Adds the multiple position.
248 259 *
249   - * @param prefix the prefix
  260 + * @param prefix
  261 + * the prefix
250 262 */
251 263 public void addMultiplePosition(String prefix) {
252 264 if (!prefix.trim().isEmpty()) {
... ... @@ -264,7 +276,8 @@ public class CodecComponent {
264 276 /**
265 277 * Adds the set position.
266 278 *
267   - * @param prefix the prefix
  279 + * @param prefix
  280 + * the prefix
268 281 */
269 282 public void addSetPosition(String prefix) {
270 283 if (!prefix.trim().isEmpty()) {
... ... @@ -282,7 +295,8 @@ public class CodecComponent {
282 295 /**
283 296 * Adds the intersecting.
284 297 *
285   - * @param prefix the prefix
  298 + * @param prefix
  299 + * the prefix
286 300 */
287 301 public void addIntersecting(String prefix) {
288 302 if (!prefix.trim().isEmpty()) {
... ... @@ -351,19 +365,32 @@ public class CodecComponent {
351 365 /**
352 366 * Instantiates a new component document.
353 367 *
354   - * @param key the key
355   - * @param prefix the prefix
356   - * @param statsType the stats type
357   - * @param regexp the regexp
358   - * @param list the list
359   - * @param listNumber the list number
360   - * @param listRegexp the list regexp
361   - * @param listExpand the list expand
362   - * @param listExpandNumber the list expand number
363   - * @param ignoreRegexp the ignore regexp
364   - * @param ignoreList the ignore list
365   - * @param ignoreListRegexp the ignore list regexp
366   - * @throws IOException Signals that an I/O exception has occurred.
  368 + * @param key
  369 + * the key
  370 + * @param prefix
  371 + * the prefix
  372 + * @param statsType
  373 + * the stats type
  374 + * @param regexp
  375 + * the regexp
  376 + * @param list
  377 + * the list
  378 + * @param listNumber
  379 + * the list number
  380 + * @param listRegexp
  381 + * the list regexp
  382 + * @param listExpand
  383 + * the list expand
  384 + * @param listExpandNumber
  385 + * the list expand number
  386 + * @param ignoreRegexp
  387 + * the ignore regexp
  388 + * @param ignoreList
  389 + * the ignore list
  390 + * @param ignoreListRegexp
  391 + * the ignore list regexp
  392 + * @throws IOException
  393 + * Signals that an I/O exception has occurred.
367 394 */
368 395 public ComponentDocument(String key, String prefix, String statsType,
369 396 String regexp, String[] list, int listNumber, Boolean listRegexp,
... ... @@ -467,15 +494,24 @@ public class CodecComponent {
467 494 /**
468 495 * Instantiates a new component kwic.
469 496 *
470   - * @param query the query
471   - * @param key the key
472   - * @param prefixes the prefixes
473   - * @param number the number
474   - * @param start the start
475   - * @param left the left
476   - * @param right the right
477   - * @param output the output
478   - * @throws IOException Signals that an I/O exception has occurred.
  497 + * @param query
  498 + * the query
  499 + * @param key
  500 + * the key
  501 + * @param prefixes
  502 + * the prefixes
  503 + * @param number
  504 + * the number
  505 + * @param start
  506 + * the start
  507 + * @param left
  508 + * the left
  509 + * @param right
  510 + * the right
  511 + * @param output
  512 + * the output
  513 + * @throws IOException
  514 + * Signals that an I/O exception has occurred.
479 515 */
480 516 public ComponentKwic(MtasSpanQuery query, String key, String prefixes,
481 517 Integer number, int start, int left, int right, String output)
... ... @@ -601,22 +637,38 @@ public class CodecComponent {
601 637 /**
602 638 * Instantiates a new component list.
603 639 *
604   - * @param spanQuery the span query
605   - * @param field the field
606   - * @param queryValue the query value
607   - * @param queryType the query type
608   - * @param queryPrefix the query prefix
609   - * @param queryVariables the query variables
610   - * @param queryIgnore the query ignore
611   - * @param queryMaximumIgnoreLength the query maximum ignore length
612   - * @param key the key
613   - * @param prefix the prefix
614   - * @param start the start
615   - * @param number the number
616   - * @param left the left
617   - * @param right the right
618   - * @param output the output
619   - * @throws IOException Signals that an I/O exception has occurred.
  640 + * @param spanQuery
  641 + * the span query
  642 + * @param field
  643 + * the field
  644 + * @param queryValue
  645 + * the query value
  646 + * @param queryType
  647 + * the query type
  648 + * @param queryPrefix
  649 + * the query prefix
  650 + * @param queryVariables
  651 + * the query variables
  652 + * @param queryIgnore
  653 + * the query ignore
  654 + * @param queryMaximumIgnoreLength
  655 + * the query maximum ignore length
  656 + * @param key
  657 + * the key
  658 + * @param prefix
  659 + * the prefix
  660 + * @param start
  661 + * the start
  662 + * @param number
  663 + * the number
  664 + * @param left
  665 + * the left
  666 + * @param right
  667 + * the right
  668 + * @param output
  669 + * the output
  670 + * @throws IOException
  671 + * Signals that an I/O exception has occurred.
620 672 */
621 673 public ComponentList(MtasSpanQuery spanQuery, String field,
622 674 String queryValue, String queryType, String queryPrefix,
... ... @@ -731,24 +783,42 @@ public class CodecComponent {
731 783 /**
732 784 * Instantiates a new component group.
733 785 *
734   - * @param spanQuery the span query
735   - * @param key the key
736   - * @param number the number
737   - * @param start the start
738   - * @param groupingHitInsidePrefixes the grouping hit inside prefixes
739   - * @param groupingHitInsideLeftPosition the grouping hit inside left position
740   - * @param groupingHitInsideLeftPrefixes the grouping hit inside left prefixes
741   - * @param groupingHitInsideRightPosition the grouping hit inside right position
742   - * @param groupingHitInsideRightPrefixes the grouping hit inside right prefixes
743   - * @param groupingHitLeftPosition the grouping hit left position
744   - * @param groupingHitLeftPrefixes the grouping hit left prefixes
745   - * @param groupingHitRightPosition the grouping hit right position
746   - * @param groupingHitRightPrefixes the grouping hit right prefixes
747   - * @param groupingLeftPosition the grouping left position
748   - * @param groupingLeftPrefixes the grouping left prefixes
749   - * @param groupingRightPosition the grouping right position
750   - * @param groupingRightPrefixes the grouping right prefixes
751   - * @throws IOException Signals that an I/O exception has occurred.
  786 + * @param spanQuery
  787 + * the span query
  788 + * @param key
  789 + * the key
  790 + * @param number
  791 + * the number
  792 + * @param start
  793 + * the start
  794 + * @param groupingHitInsidePrefixes
  795 + * the grouping hit inside prefixes
  796 + * @param groupingHitInsideLeftPosition
  797 + * the grouping hit inside left position
  798 + * @param groupingHitInsideLeftPrefixes
  799 + * the grouping hit inside left prefixes
  800 + * @param groupingHitInsideRightPosition
  801 + * the grouping hit inside right position
  802 + * @param groupingHitInsideRightPrefixes
  803 + * the grouping hit inside right prefixes
  804 + * @param groupingHitLeftPosition
  805 + * the grouping hit left position
  806 + * @param groupingHitLeftPrefixes
  807 + * the grouping hit left prefixes
  808 + * @param groupingHitRightPosition
  809 + * the grouping hit right position
  810 + * @param groupingHitRightPrefixes
  811 + * the grouping hit right prefixes
  812 + * @param groupingLeftPosition
  813 + * the grouping left position
  814 + * @param groupingLeftPrefixes
  815 + * the grouping left prefixes
  816 + * @param groupingRightPosition
  817 + * the grouping right position
  818 + * @param groupingRightPrefixes
  819 + * the grouping right prefixes
  820 + * @throws IOException
  821 + * Signals that an I/O exception has occurred.
752 822 */
753 823 public ComponentGroup(MtasSpanQuery spanQuery, String key, int number,
754 824 int start, String groupingHitInsidePrefixes,
... ... @@ -808,11 +878,15 @@ public class CodecComponent {
808 878 /**
809 879 * Creates the positioned prefixes.
810 880 *
811   - * @param prefixList the prefix list
812   - * @param position the position
813   - * @param prefixes the prefixes
  881 + * @param prefixList
  882 + * the prefix list
  883 + * @param position
  884 + * the position
  885 + * @param prefixes
  886 + * the prefixes
814 887 * @return the hash set[]
815   - * @throws IOException Signals that an I/O exception has occurred.
  888 + * @throws IOException
  889 + * Signals that an I/O exception has occurred.
816 890 */
817 891 private static HashSet<String>[] createPositionedPrefixes(
818 892 HashSet<String> prefixList, String[] position, String[] prefixes)
... ... @@ -966,24 +1040,42 @@ public class CodecComponent {
966 1040 /**
967 1041 * Instantiates a new component facet.
968 1042 *
969   - * @param spanQueries the span queries
970   - * @param field the field
971   - * @param key the key
972   - * @param baseFields the base fields
973   - * @param baseFieldTypes the base field types
974   - * @param baseTypes the base types
975   - * @param baseRangeSizes the base range sizes
976   - * @param baseRangeBases the base range bases
977   - * @param baseSortTypes the base sort types
978   - * @param baseSortDirections the base sort directions
979   - * @param baseNumbers the base numbers
980   - * @param baseMinimumDoubles the base minimum doubles
981   - * @param baseMaximumDoubles the base maximum doubles
982   - * @param baseFunctionKeys the base function keys
983   - * @param baseFunctionExpressions the base function expressions
984   - * @param baseFunctionTypes the base function types
985   - * @throws IOException Signals that an I/O exception has occurred.
986   - * @throws ParseException the parse exception
  1043 + * @param spanQueries
  1044 + * the span queries
  1045 + * @param field
  1046 + * the field
  1047 + * @param key
  1048 + * the key
  1049 + * @param baseFields
  1050 + * the base fields
  1051 + * @param baseFieldTypes
  1052 + * the base field types
  1053 + * @param baseTypes
  1054 + * the base types
  1055 + * @param baseRangeSizes
  1056 + * the base range sizes
  1057 + * @param baseRangeBases
  1058 + * the base range bases
  1059 + * @param baseSortTypes
  1060 + * the base sort types
  1061 + * @param baseSortDirections
  1062 + * the base sort directions
  1063 + * @param baseNumbers
  1064 + * the base numbers
  1065 + * @param baseMinimumDoubles
  1066 + * the base minimum doubles
  1067 + * @param baseMaximumDoubles
  1068 + * the base maximum doubles
  1069 + * @param baseFunctionKeys
  1070 + * the base function keys
  1071 + * @param baseFunctionExpressions
  1072 + * the base function expressions
  1073 + * @param baseFunctionTypes
  1074 + * the base function types
  1075 + * @throws IOException
  1076 + * Signals that an I/O exception has occurred.
  1077 + * @throws ParseException
  1078 + * the parse exception
987 1079 */
988 1080 @SuppressWarnings("unchecked")
989 1081 public ComponentFacet(MtasSpanQuery[] spanQueries, String field, String key,
... ... @@ -1246,36 +1338,61 @@ public class CodecComponent {
1246 1338 /**
1247 1339 * Instantiates a new component term vector.
1248 1340 *
1249   - * @param key the key
1250   - * @param prefix the prefix
1251   - * @param distanceKey the distance key
1252   - * @param distanceType the distance type
1253   - * @param distanceBase the distance base
1254   - * @param distanceParameter the distance parameter
1255   - * @param distanceMaximum the distance maximum
1256   - * @param regexp the regexp
1257   - * @param full the full
1258   - * @param type the type
1259   - * @param sortType the sort type
1260   - * @param sortDirection the sort direction
1261   - * @param startValue the start value
1262   - * @param number the number
1263   - * @param functionKey the function key
1264   - * @param functionExpression the function expression
1265   - * @param functionType the function type
1266   - * @param boundary the boundary
1267   - * @param list the list
1268   - * @param listRegexp the list regexp
1269   - * @param ignoreRegexp the ignore regexp
1270   - * @param ignoreList the ignore list
1271   - * @param ignoreListRegexp the ignore list regexp
1272   - * @throws IOException Signals that an I/O exception has occurred.
1273   - * @throws ParseException the parse exception
  1341 + * @param key
  1342 + * the key
  1343 + * @param prefix
  1344 + * the prefix
  1345 + * @param distanceKey
  1346 + * the distance key
  1347 + * @param distanceType
  1348 + * the distance type
  1349 + * @param distanceBase
  1350 + * the distance base
  1351 + * @param distanceParameter
  1352 + * the distance parameter
  1353 + * @param distanceMaximum
  1354 + * the distance maximum
  1355 + * @param regexp
  1356 + * the regexp
  1357 + * @param full
  1358 + * the full
  1359 + * @param type
  1360 + * the type
  1361 + * @param sortType
  1362 + * the sort type
  1363 + * @param sortDirection
  1364 + * the sort direction
  1365 + * @param startValue
  1366 + * the start value
  1367 + * @param number
  1368 + * the number
  1369 + * @param functionKey
  1370 + * the function key
  1371 + * @param functionExpression
  1372 + * the function expression
  1373 + * @param functionType
  1374 + * the function type
  1375 + * @param boundary
  1376 + * the boundary
  1377 + * @param list
  1378 + * the list
  1379 + * @param listRegexp
  1380 + * the list regexp
  1381 + * @param ignoreRegexp
  1382 + * the ignore regexp
  1383 + * @param ignoreList
  1384 + * the ignore list
  1385 + * @param ignoreListRegexp
  1386 + * the ignore list regexp
  1387 + * @throws IOException
  1388 + * Signals that an I/O exception has occurred.
  1389 + * @throws ParseException
  1390 + * the parse exception
1274 1391 */
1275 1392 @SuppressWarnings({ "unchecked", "rawtypes" })
1276 1393 public ComponentTermVector(String key, String prefix, String[] distanceKey,
1277 1394 String[] distanceType, String[] distanceBase, Map[] distanceParameter,
1278   - String[] distanceMaximum, String regexp, Boolean full, String type,
  1395 + String[] distanceMinimum, String[] distanceMaximum, String regexp, Boolean full, String type,
1279 1396 String sortType, String sortDirection, String startValue, int number,
1280 1397 String[] functionKey, String[] functionExpression,
1281 1398 String[] functionType, String boundary, String[] list,
... ... @@ -1293,7 +1410,7 @@ public class CodecComponent {
1293 1410 for (int i = 0; i < distanceKey.length; i++) {
1294 1411 SubComponentDistance item = new SubComponentDistance(distanceKey[i],
1295 1412 distanceType[i], this.prefix, distanceBase[i],
1296   - distanceParameter[i], distanceMaximum[i]);
  1413 + distanceParameter[i], distanceMinimum[i], distanceMaximum[i]);
1297 1414 distances.add(item);
1298 1415 }
1299 1416 }
... ... @@ -1450,6 +1567,34 @@ public class CodecComponent {
1450 1567 }
1451 1568  
1452 1569 /**
  1570 + * The Class ComponentStatus.
  1571 + */
  1572 + public static class ComponentStatus implements BasicComponent {
  1573 +
  1574 + public String handler;
  1575 + public String name;
  1576 + public String key;
  1577 + public Integer numberOfDocuments;
  1578 + public Integer numberOfSegments;
  1579 + public boolean getMtasHandler;
  1580 + public boolean getNumberOfDocuments;
  1581 + public boolean getNumberOfSegments;
  1582 +
  1583 + public ComponentStatus(String name, String key, boolean getMtasHandler,
  1584 + boolean getNumberOfDocuments, boolean getNumberOfSegments) {
  1585 + this.name = Objects.requireNonNull(name, "no name");
  1586 + this.key = key;
  1587 + this.getMtasHandler = getMtasHandler;
  1588 + this.getNumberOfDocuments = getNumberOfDocuments;
  1589 + this.getNumberOfSegments = getNumberOfSegments;
  1590 + handler = null;
  1591 + numberOfDocuments = null;
  1592 + numberOfSegments = null;
  1593 + }
  1594 +
  1595 + }
  1596 +
  1597 + /**
1453 1598 * The Interface ComponentStats.
1454 1599 */
1455 1600 public abstract static interface ComponentStats extends BasicComponent {
... ... @@ -1493,16 +1638,26 @@ public class CodecComponent {
1493 1638 /**
1494 1639 * Instantiates a new component span.
1495 1640 *
1496   - * @param queries the queries
1497   - * @param key the key
1498   - * @param minimumDouble the minimum double
1499   - * @param maximumDouble the maximum double
1500   - * @param type the type
1501   - * @param functionKey the function key
1502   - * @param functionExpression the function expression
1503   - * @param functionType the function type
1504   - * @throws IOException Signals that an I/O exception has occurred.
1505   - * @throws ParseException the parse exception
  1641 + * @param queries
  1642 + * the queries
  1643 + * @param key
  1644 + * the key
  1645 + * @param minimumDouble
  1646 + * the minimum double
  1647 + * @param maximumDouble
  1648 + * the maximum double
  1649 + * @param type
  1650 + * the type
  1651 + * @param functionKey
  1652 + * the function key
  1653 + * @param functionExpression
  1654 + * the function expression
  1655 + * @param functionType
  1656 + * the function type
  1657 + * @throws IOException
  1658 + * Signals that an I/O exception has occurred.
  1659 + * @throws ParseException
  1660 + * the parse exception
1506 1661 */
1507 1662 public ComponentSpan(MtasSpanQuery[] queries, String key,
1508 1663 Double minimumDouble, Double maximumDouble, String type,
... ... @@ -1635,12 +1790,18 @@ public class CodecComponent {
1635 1790 /**
1636 1791 * Instantiates a new component position.
1637 1792 *
1638   - * @param key the key
1639   - * @param minimumDouble the minimum double
1640   - * @param maximumDouble the maximum double
1641   - * @param statsType the stats type
1642   - * @throws IOException Signals that an I/O exception has occurred.
1643   - * @throws ParseException the parse exception
  1793 + * @param key
  1794 + * the key
  1795 + * @param minimumDouble
  1796 + * the minimum double
  1797 + * @param maximumDouble
  1798 + * the maximum double
  1799 + * @param statsType
  1800 + * the stats type
  1801 + * @throws IOException
  1802 + * Signals that an I/O exception has occurred.
  1803 + * @throws ParseException
  1804 + * the parse exception
1644 1805 */
1645 1806 public ComponentPosition(String key, Double minimumDouble,
1646 1807 Double maximumDouble, String statsType)
... ... @@ -1694,12 +1855,18 @@ public class CodecComponent {
1694 1855 /**
1695 1856 * Instantiates a new component token.
1696 1857 *
1697   - * @param key the key
1698   - * @param minimumDouble the minimum double
1699   - * @param maximumDouble the maximum double
1700   - * @param statsType the stats type
1701   - * @throws IOException Signals that an I/O exception has occurred.
1702   - * @throws ParseException the parse exception
  1858 + * @param key
  1859 + * the key
  1860 + * @param minimumDouble
  1861 + * the minimum double
  1862 + * @param maximumDouble
  1863 + * the maximum double
  1864 + * @param statsType
  1865 + * the stats type
  1866 + * @throws IOException
  1867 + * Signals that an I/O exception has occurred.
  1868 + * @throws ParseException
  1869 + * the parse exception
1703 1870 */
1704 1871 public ComponentToken(String key, Double minimumDouble,
1705 1872 Double maximumDouble, String statsType)
... ... @@ -1774,8 +1941,10 @@ public class CodecComponent {
1774 1941 /**
1775 1942 * Instantiates a new component collection.
1776 1943 *
1777   - * @param key the key
1778   - * @param action the action
  1944 + * @param key
  1945 + * the key
  1946 + * @param action
  1947 + * the action
1779 1948 */
1780 1949 public ComponentCollection(String key, String action) {
1781 1950 this.key = key;
... ... @@ -1787,7 +1956,8 @@ public class CodecComponent {
1787 1956 /**
1788 1957 * Sets the list variables.
1789 1958 *
1790   - * @throws IOException Signals that an I/O exception has occurred.
  1959 + * @throws IOException
  1960 + * Signals that an I/O exception has occurred.
1791 1961 */
1792 1962 public void setListVariables() throws IOException {
1793 1963 if (action.equals(ACTION_LIST)) {
... ... @@ -1800,9 +1970,12 @@ public class CodecComponent {
1800 1970 /**
1801 1971 * Sets the create variables.
1802 1972 *
1803   - * @param id the id
1804   - * @param fields the fields
1805   - * @throws IOException Signals that an I/O exception has occurred.
  1973 + * @param id
  1974 + * the id
  1975 + * @param fields
  1976 + * the fields
  1977 + * @throws IOException
  1978 + * Signals that an I/O exception has occurred.
1806 1979 */
1807 1980 public void setCreateVariables(String id, Set<String> fields)
1808 1981 throws IOException {
... ... @@ -1817,8 +1990,10 @@ public class CodecComponent {
1817 1990 /**
1818 1991 * Sets the check variables.
1819 1992 *
1820   - * @param id the new check variables
1821   - * @throws IOException Signals that an I/O exception has occurred.
  1993 + * @param id
  1994 + * the new check variables
  1995 + * @throws IOException
  1996 + * Signals that an I/O exception has occurred.
1822 1997 */
1823 1998 public void setCheckVariables(String id) throws IOException {
1824 1999 if (action.equals(ACTION_CHECK)) {
... ... @@ -1831,8 +2006,10 @@ public class CodecComponent {
1831 2006 /**
1832 2007 * Sets the gets the variables.
1833 2008 *
1834   - * @param id the new gets the variables
1835   - * @throws IOException Signals that an I/O exception has occurred.
  2009 + * @param id
  2010 + * the new gets the variables
  2011 + * @throws IOException
  2012 + * Signals that an I/O exception has occurred.
1836 2013 */
1837 2014 public void setGetVariables(String id) throws IOException {
1838 2015 if (action.equals(ACTION_GET)) {
... ... @@ -1845,9 +2022,12 @@ public class CodecComponent {
1845 2022 /**
1846 2023 * Sets the post variables.
1847 2024 *
1848   - * @param id the id
1849   - * @param values the values
1850   - * @throws IOException Signals that an I/O exception has occurred.
  2025 + * @param id
  2026 + * the id
  2027 + * @param values
  2028 + * the values
  2029 + * @throws IOException
  2030 + * Signals that an I/O exception has occurred.
1851 2031 */
1852 2032 public void setPostVariables(String id, HashSet<String> values)
1853 2033 throws IOException {
... ... @@ -1862,10 +2042,14 @@ public class CodecComponent {
1862 2042 /**
1863 2043 * Sets the import variables.
1864 2044 *
1865   - * @param id the id
1866   - * @param url the url
1867   - * @param collection the collection
1868   - * @throws IOException Signals that an I/O exception has occurred.
  2045 + * @param id
  2046 + * the id
  2047 + * @param url
  2048 + * the url
  2049 + * @param collection
  2050 + * the collection
  2051 + * @throws IOException
  2052 + * Signals that an I/O exception has occurred.
1869 2053 */
1870 2054 public void setImportVariables(String id, String url, String collection)
1871 2055 throws IOException {
... ... @@ -1923,9 +2107,11 @@ public class CodecComponent {
1923 2107 /**
1924 2108 * Gets the import.
1925 2109 *
1926   - * @param collectionGetUrl the collection get url
  2110 + * @param collectionGetUrl
  2111 + * the collection get url
1927 2112 * @return the import
1928   - * @throws IOException Signals that an I/O exception has occurred.
  2113 + * @throws IOException
  2114 + * Signals that an I/O exception has occurred.
1929 2115 */
1930 2116 private Map<String, Object> getImport(String collectionGetUrl)
1931 2117 throws IOException {
... ... @@ -1957,8 +2143,10 @@ public class CodecComponent {
1957 2143 /**
1958 2144 * Sets the delete variables.
1959 2145 *
1960   - * @param id the new delete variables
1961   - * @throws IOException Signals that an I/O exception has occurred.
  2146 + * @param id
  2147 + * the new delete variables
  2148 + * @throws IOException
  2149 + * Signals that an I/O exception has occurred.
1962 2150 */
1963 2151 public void setDeleteVariables(String id) throws IOException {
1964 2152 if (action.equals(ACTION_DELETE)) {
... ... @@ -1998,8 +2186,10 @@ public class CodecComponent {
1998 2186 /**
1999 2187 * Adds the value.
2000 2188 *
2001   - * @param value the value
2002   - * @throws IOException Signals that an I/O exception has occurred.
  2189 + * @param value
  2190 + * the value
  2191 + * @throws IOException
  2192 + * Signals that an I/O exception has occurred.
2003 2193 */
2004 2194 public void addValue(String value) throws IOException {
2005 2195 if (action.equals(ACTION_CREATE)) {
... ... @@ -2016,8 +2206,10 @@ public class CodecComponent {
2016 2206 /**
2017 2207 * Gets the params from JSON.
2018 2208 *
2019   - * @param params the params
2020   - * @param json the json
  2209 + * @param params
  2210 + * the params
  2211 + * @param json
  2212 + * the json
2021 2213 * @return the params from JSON
2022 2214 */
2023 2215 private static void getParamsFromJSON(Map<String, Object> params,
... ... @@ -2078,6 +2270,8 @@ public class CodecComponent {
2078 2270 /** The prefix. */
2079 2271 public String prefix;
2080 2272  
  2273 + public Double minimum;
  2274 +
2081 2275 /** The maximum. */
2082 2276 public Double maximum;
2083 2277  
... ... @@ -2093,23 +2287,33 @@ public class CodecComponent {
2093 2287 /** The Constant NAME_DAMERAULEVENSHTEIN. */
2094 2288 private static final String NAME_DAMERAULEVENSHTEIN = "damerau-levenshtein";
2095 2289  
  2290 + /** The Constant NAME_MORSE. */
  2291 + private static final String NAME_MORSE = "morse";
  2292 +
2096 2293 /**
2097 2294 * Instantiates a new sub component distance.
2098 2295 *
2099   - * @param key the key
2100   - * @param type the type
2101   - * @param prefix the prefix
2102   - * @param base the base
2103   - * @param parameters the parameters
2104   - * @param maximum the maximum
  2296 + * @param key
  2297 + * the key
  2298 + * @param type
  2299 + * the type
  2300 + * @param prefix
  2301 + * the prefix
  2302 + * @param base
  2303 + * the base
  2304 + * @param parameters
  2305 + * the parameters
  2306 + * @param maximum
  2307 + * the maximum
2105 2308 */
2106 2309 public SubComponentDistance(String key, String type, String prefix,
2107   - String base, Map<String, String> parameters, String maximum) {
  2310 + String base, Map<String, String> parameters, String minimum, String maximum) {
2108 2311 this.key = key;
2109 2312 this.prefix = prefix;
2110 2313 this.type = type;
2111 2314 this.base = base;
2112 2315 this.parameters = parameters;
  2316 + this.minimum = minimum != null ? Double.parseDouble(minimum) : null;
2113 2317 this.maximum = maximum != null ? Double.parseDouble(maximum) : null;
2114 2318 }
2115 2319  
... ... @@ -2117,21 +2321,54 @@ public class CodecComponent {
2117 2321 * Gets the distance.
2118 2322 *
2119 2323 * @return the distance
2120   - * @throws IOException Signals that an I/O exception has occurred.
  2324 + * @throws IOException
  2325 + * Signals that an I/O exception has occurred.
2121 2326 */
2122 2327 public Distance getDistance() throws IOException {
2123 2328 if (distance == null) {
2124   - if (type != null && type.equals(NAME_LEVENSHTEIN)) {
2125   - distance = new LevenshteinDistance(prefix, base, maximum, parameters);
2126   - } else if (type != null && type.equals(NAME_DAMERAULEVENSHTEIN)) {
2127   - distance = new DamerauLevenshteinDistance(prefix, base, maximum,
2128   - parameters);
  2329 + if (type != null) {
  2330 + try {
  2331 + Constructor<Distance> constructor = (Constructor<Distance>) Class
  2332 + .forName("mtas.codec.util.distance." + createClassName(type)
  2333 + + "Distance")
  2334 + .getConstructor(String.class, String.class, Double.class, Double.class,
  2335 + Map.class);
  2336 + distance = constructor.newInstance(prefix, base, minimum, maximum,
  2337 + parameters);
  2338 + } catch (ClassNotFoundException | NoSuchMethodException
  2339 + | SecurityException | InstantiationException
  2340 + | IllegalAccessException | IllegalArgumentException
  2341 + | InvocationTargetException e) {
  2342 + throw new IllegalStateException(e);
  2343 + }
  2344 + // distance = new MorseDistance(prefix, base, maximum, parameters);
2129 2345 } else {
2130 2346 throw new IOException("unrecognized distance " + type);
2131 2347 }
2132 2348 }
2133 2349 return distance;
2134 2350 }
  2351 +
  2352 + private String createClassName(String type) {
  2353 + final char DASH = '-';
  2354 + Objects.requireNonNull(type, "Type is obligatory");
  2355 + final StringBuilder output = new StringBuilder(type.length());
  2356 + boolean lastCharacterWasDash = true;
  2357 + boolean thisCharacterWasDash;
  2358 + for (final char currentCharacter : type.toCharArray()) {
  2359 + thisCharacterWasDash = (currentCharacter == DASH);
  2360 + if (!thisCharacterWasDash) {
  2361 + if (lastCharacterWasDash) {
  2362 + output.append(Character.toTitleCase(currentCharacter));
  2363 + } else {
  2364 + output.append(currentCharacter);
  2365 + }
  2366 + }
  2367 + lastCharacterWasDash = thisCharacterWasDash;
  2368 + }
  2369 + return output.toString();
  2370 + }
  2371 +
2135 2372 }
2136 2373  
2137 2374 /**
... ... @@ -2172,18 +2409,30 @@ public class CodecComponent {
2172 2409 /**
2173 2410 * Instantiates a new sub component function.
2174 2411 *
2175   - * @param collectorType the collector type
2176   - * @param key the key
2177   - * @param type the type
2178   - * @param parserFunction the parser function
2179   - * @param sortType the sort type
2180   - * @param sortDirection the sort direction
2181   - * @param start the start
2182   - * @param number the number
2183   - * @param segmentRegistration the segment registration
2184   - * @param boundary the boundary
2185   - * @throws ParseException the parse exception
2186   - * @throws IOException Signals that an I/O exception has occurred.
  2412 + * @param collectorType
  2413 + * the collector type
  2414 + * @param key
  2415 + * the key
  2416 + * @param type
  2417 + * the type
  2418 + * @param parserFunction
  2419 + * the parser function
  2420 + * @param sortType
  2421 + * the sort type
  2422 + * @param sortDirection
  2423 + * the sort direction
  2424 + * @param start
  2425 + * the start
  2426 + * @param number
  2427 + * the number
  2428 + * @param segmentRegistration
  2429 + * the segment registration
  2430 + * @param boundary
  2431 + * the boundary
  2432 + * @throws ParseException
  2433 + * the parse exception
  2434 + * @throws IOException
  2435 + * Signals that an I/O exception has occurred.
2187 2436 */
2188 2437 public SubComponentFunction(String collectorType, String key, String type,
2189 2438 MtasFunctionParserFunction parserFunction, String sortType,
... ... @@ -2216,12 +2465,18 @@ public class CodecComponent {
2216 2465 /**
2217 2466 * Instantiates a new sub component function.
2218 2467 *
2219   - * @param collectorType the collector type
2220   - * @param key the key
2221   - * @param expression the expression
2222   - * @param type the type
2223   - * @throws ParseException the parse exception
2224   - * @throws IOException Signals that an I/O exception has occurred.
  2468 + * @param collectorType
  2469 + * the collector type
  2470 + * @param key
  2471 + * the key
  2472 + * @param expression
  2473 + * the expression
  2474 + * @param type
  2475 + * the type
  2476 + * @throws ParseException
  2477 + * the parse exception
  2478 + * @throws IOException
  2479 + * Signals that an I/O exception has occurred.
2225 2480 */
2226 2481 public SubComponentFunction(String collectorType, String key,
2227 2482 String expression, String type) throws ParseException, IOException {
... ... @@ -2264,8 +2519,10 @@ public class CodecComponent {
2264 2519 /**
2265 2520 * Instantiates a new kwic token.
2266 2521 *
2267   - * @param match the match
2268   - * @param tokens the tokens
  2522 + * @param match
  2523 + * the match
  2524 + * @param tokens
  2525 + * the tokens
2269 2526 */
2270 2527 public KwicToken(Match match, List<MtasTokenString> tokens) {
2271 2528 startPosition = match.startPosition;
... ... @@ -2292,8 +2549,10 @@ public class CodecComponent {
2292 2549 /**
2293 2550 * Instantiates a new kwic hit.
2294 2551 *
2295   - * @param match the match
2296   - * @param hits the hits
  2552 + * @param match
  2553 + * the match
  2554 + * @param hits
  2555 + * the hits
2297 2556 */
2298 2557 public KwicHit(Match match, Map<Integer, List<String>> hits) {
2299 2558 startPosition = match.startPosition;
... ... @@ -2365,7 +2624,8 @@ public class CodecComponent {
2365 2624 /**
2366 2625 * Sort.
2367 2626 *
2368   - * @param data the data
  2627 + * @param data
  2628 + * the data
2369 2629 * @return the list
2370 2630 */
2371 2631 private List<MtasTreeHit<String>> sort(List<MtasTreeHit<String>> data) {
... ... @@ -2384,14 +2644,22 @@ public class CodecComponent {
2384 2644 /**
2385 2645 * Instantiates a new group hit.
2386 2646 *
2387   - * @param list the list
2388   - * @param start the start
2389   - * @param end the end
2390   - * @param hitStart the hit start
2391   - * @param hitEnd the hit end
2392   - * @param group the group
2393   - * @param knownPrefixes the known prefixes
2394   - * @throws UnsupportedEncodingException the unsupported encoding exception
  2647 + * @param list
  2648 + * the list
  2649 + * @param start
  2650 + * the start
  2651 + * @param end
  2652 + * the end
  2653 + * @param hitStart
  2654 + * the hit start
  2655 + * @param hitEnd
  2656 + * the hit end
  2657 + * @param group
  2658 + * the group
  2659 + * @param knownPrefixes
  2660 + * the known prefixes
  2661 + * @throws UnsupportedEncodingException
  2662 + * the unsupported encoding exception
2395 2663 */
2396 2664 @SuppressWarnings("unchecked")
2397 2665 public GroupHit(List<MtasTreeHit<String>> list, int start, int end,
... ... @@ -2700,8 +2968,10 @@ public class CodecComponent {
2700 2968 /**
2701 2969 * Data equals.
2702 2970 *
2703   - * @param d1 the d 1
2704   - * @param d2 the d 2
  2971 + * @param d1
  2972 + * the d 1
  2973 + * @param d2
  2974 + * the d 2
2705 2975 * @return true, if successful
2706 2976 */
2707 2977 private boolean dataEquals(List<String>[] d1, List<String>[] d2) {
... ... @@ -2761,11 +3031,15 @@ public class CodecComponent {
2761 3031 /**
2762 3032 * Data to string.
2763 3033 *
2764   - * @param data the data
2765   - * @param missing the missing
2766   - * @param reverse the reverse
  3034 + * @param data
  3035 + * the data
  3036 + * @param missing
  3037 + * the missing
  3038 + * @param reverse
  3039 + * the reverse
2767 3040 * @return the string
2768   - * @throws UnsupportedEncodingException the unsupported encoding exception
  3041 + * @throws UnsupportedEncodingException
  3042 + * the unsupported encoding exception
2769 3043 */
2770 3044 private String dataToString(List<String>[] data, Set<String>[] missing,
2771 3045 boolean reverse) throws UnsupportedEncodingException {
... ... @@ -2831,8 +3105,10 @@ public class CodecComponent {
2831 3105 /**
2832 3106 * Key to sub sub object.
2833 3107 *
2834   - * @param key the key
2835   - * @param newKey the new key
  3108 + * @param key
  3109 + * the key
  3110 + * @param newKey
  3111 + * the new key
2836 3112 * @return the map[]
2837 3113 */
2838 3114 private static Map<String, String>[] keyToSubSubObject(String key,
... ... @@ -2899,8 +3175,10 @@ public class CodecComponent {
2899 3175 /**
2900 3176 * Key to sub object.
2901 3177 *
2902   - * @param key the key
2903   - * @param newKey the new key
  3178 + * @param key
  3179 + * the key
  3180 + * @param newKey
  3181 + * the new key
2904 3182 * @return the map
2905 3183 */
2906 3184 private static Map<Integer, Map<String, String>[]> keyToSubObject(
... ... @@ -2924,8 +3202,10 @@ public class CodecComponent {
2924 3202 /**
2925 3203 * Key to object.
2926 3204 *
2927   - * @param key the key
2928   - * @param newKey the new key
  3205 + * @param key
  3206 + * the key
  3207 + * @param newKey
  3208 + * the new key
2929 3209 * @return the map
2930 3210 */
2931 3211 public static Map<String, Map<Integer, Map<String, String>[]>> keyToObject(
... ... @@ -2990,10 +3270,14 @@ public class CodecComponent {
2990 3270 /**
2991 3271 * Instantiates a new list token.
2992 3272 *
2993   - * @param docId the doc id
2994   - * @param docPosition the doc position
2995   - * @param match the match
2996   - * @param tokens the tokens
  3273 + * @param docId
  3274 + * the doc id
  3275 + * @param docPosition
  3276 + * the doc position
  3277 + * @param match
  3278 + * the match
  3279 + * @param tokens
  3280 + * the tokens
2997 3281 */
2998 3282 public ListToken(Integer docId, Integer docPosition, Match match,
2999 3283 List<MtasTokenString> tokens) {
... ... @@ -3028,10 +3312,14 @@ public class CodecComponent {
3028 3312 /**
3029 3313 * Instantiates a new list hit.
3030 3314 *
3031   - * @param docId the doc id
3032   - * @param docPosition the doc position
3033   - * @param match the match
3034   - * @param hits the hits
  3315 + * @param docId
  3316 + * the doc id
  3317 + * @param docPosition
  3318 + * the doc position
  3319 + * @param match
  3320 + * the match
  3321 + * @param hits
  3322 + * the hits
3035 3323 */
3036 3324 public ListHit(Integer docId, Integer docPosition, Match match,
3037 3325 Map<Integer, List<String>> hits) {
... ... @@ -3057,8 +3345,10 @@ public class CodecComponent {
3057 3345 /**
3058 3346 * Instantiates a new match.
3059 3347 *
3060   - * @param startPosition the start position
3061   - * @param endPosition the end position
  3348 + * @param startPosition
  3349 + * the start position
  3350 + * @param endPosition
  3351 + * the end position
3062 3352 */
3063 3353 public Match(int startPosition, int endPosition) {
3064 3354 this.startPosition = startPosition;
... ...
src/main/java/mtas/codec/util/CodecUtil.java
... ... @@ -243,7 +243,7 @@ public class CodecUtil {
243 243 */
244 244 public static void collectField(String field, IndexSearcher searcher,
245 245 IndexReader rawReader, ArrayList<Integer> fullDocList,
246   - ArrayList<Integer> fullDocSet, ComponentField fieldStats)
  246 + ArrayList<Integer> fullDocSet, ComponentField fieldStats, Status status)
247 247 throws IllegalAccessException, IllegalArgumentException,
248 248 InvocationTargetException, IOException {
249 249 if (fieldStats != null) {
... ... @@ -259,7 +259,7 @@ public class CodecUtil {
259 259 }
260 260 // collect
261 261 CodecCollector.collectField(field, searcher, reader, rawReader,
262   - fullDocList, fullDocSet, fieldStats, spansQueryWeight);
  262 + fullDocList, fullDocSet, fieldStats, spansQueryWeight, status);
263 263 }
264 264 }
265 265  
... ...
src/main/java/mtas/codec/util/distance/DamerauLevenshteinDistance.java
... ... @@ -32,9 +32,9 @@ public class DamerauLevenshteinDistance extends LevenshteinDistance {
32 32 * @param parameters the parameters
33 33 * @throws IOException Signals that an I/O exception has occurred.
34 34 */
35   - public DamerauLevenshteinDistance(String prefix, String base, Double maximum,
  35 + public DamerauLevenshteinDistance(String prefix, String base, Double minimum, Double maximum,
36 36 Map<String, String> parameters) throws IOException {
37   - super(prefix, base, maximum, parameters);
  37 + super(prefix, base, minimum, maximum, parameters);
38 38 transpositionDistance = defaultTranspositionDistance;
39 39 if (parameters != null) {
40 40 for (Entry<String, String> entry : parameters.entrySet()) {
... ... @@ -56,14 +56,14 @@ public class DamerauLevenshteinDistance extends LevenshteinDistance {
56 56 * util.BytesRef)
57 57 */
58 58 @Override
59   - public boolean validate(BytesRef term) {
  59 + public boolean validateMaximum(BytesRef term) {
60 60 if (maximum == null) {
61 61 return true;
62 62 } else {
63 63 double[][] state = _start();
64 64 char ch1;
65 65 char ch2 = 0x00;
66   - int i = term.offset + MtasToken.DELIMITER.length() + prefix.length();
  66 + int i = term.offset + prefixOffset;
67 67 for (; i < term.length; i++) {
68 68 ch1 = (char) term.bytes[i];
69 69 if (ch1 == 0x00) {
... ... @@ -78,6 +78,23 @@ public class DamerauLevenshteinDistance extends LevenshteinDistance {
78 78 return _is_match(state);
79 79 }
80 80 }
  81 +
  82 + @Override
  83 + public double compute(BytesRef term) {
  84 + double[][] state = _start();
  85 + char ch1;
  86 + char ch2 = 0x00;
  87 + int i = term.offset + prefixOffset;
  88 + for (; i < term.length; i++) {
  89 + ch1 = (char) term.bytes[i];
  90 + if (ch1 == 0x00) {
  91 + break;
  92 + }
  93 + state = _step(state, ch1, ch2);
  94 + ch2 = ch1;
  95 + }
  96 + return _distance(state);
  97 + }
81 98  
82 99 /*
83 100 * (non-Javadoc)
... ... @@ -157,7 +174,7 @@ public class DamerauLevenshteinDistance extends LevenshteinDistance {
157 174 * @return true, if successful
158 175 */
159 176 private boolean _is_match(double[][] state) {
160   - return state[2][state[2].length - 1] <= maximum;
  177 + return state[2][state[2].length - 1] < maximum;
161 178 }
162 179  
163 180 /**
... ... @@ -168,7 +185,7 @@ public class DamerauLevenshteinDistance extends LevenshteinDistance {
168 185 */
169 186 private boolean _can_match(double[][] state) {
170 187 for (double d : state[2]) {
171   - if (d <= maximum) {
  188 + if (d < maximum) {
172 189 return true;
173 190 }
174 191 }
... ...
src/main/java/mtas/codec/util/distance/Distance.java
... ... @@ -5,24 +5,40 @@ import java.util.Map;
5 5  
6 6 import org.apache.lucene.util.BytesRef;
7 7  
  8 +import mtas.analysis.token.MtasToken;
  9 +
8 10 public abstract class Distance {
9 11  
10 12 protected final String prefix;
11 13 protected final String base;
12   - protected final Double maximum;
  14 + public final Double minimum;
  15 + public final Double maximum;
13 16 protected final Map<String,String> parameters;
  17 + protected final int prefixOffset;
  18 +
  19 + private static final double DOUBLE_TOLERANCE = 5E-16;
14 20  
15 21 public static final String NAME = "distance";
16 22  
17   - public Distance(String prefix, String base, Double maximum, Map<String,String> parameters) throws IOException {
  23 + public Distance(String prefix, String base, Double minimum, Double maximum, Map<String,String> parameters) throws IOException {
18 24 this.prefix = prefix;
19 25 this.base = base;
20   - this.maximum = maximum;
  26 + this.minimum = minimum==null?null:minimum-DOUBLE_TOLERANCE;
  27 + this.maximum = maximum==null?null:maximum+DOUBLE_TOLERANCE;
21 28 this.parameters = parameters;
  29 + prefixOffset = prefix.length() + MtasToken.DELIMITER.length();
22 30 }
23 31  
  32 + public abstract double compute(BytesRef term);
  33 +
24 34 public abstract double compute(String key);
25 35  
26   - public abstract boolean validate(BytesRef term);
  36 + public boolean validate(BytesRef term) {
  37 + return validateMaximum(term) && validateMinimum(term);
  38 + }
  39 +
  40 + public abstract boolean validateMaximum(BytesRef term);
  41 +
  42 + public abstract boolean validateMinimum(BytesRef term);
27 43  
28 44 }
... ...
src/main/java/mtas/codec/util/distance/LevenshteinDistance.java
... ... @@ -52,9 +52,9 @@ public class LevenshteinDistance extends Distance {
52 52 * @param parameters the parameters
53 53 * @throws IOException Signals that an I/O exception has occurred.
54 54 */
55   - public LevenshteinDistance(String prefix, String base, Double maximum,
  55 + public LevenshteinDistance(String prefix, String base, Double minimum, Double maximum,
56 56 Map<String, String> parameters) throws IOException {
57   - super(prefix, base, maximum, parameters);
  57 + super(prefix, base, minimum, maximum, parameters);
58 58 deletionDistance = defaultDeletionDistance;
59 59 insertionDistance = defaultInsertionDistance;
60 60 replaceDistance = defaultReplaceDistance;
... ... @@ -84,13 +84,13 @@ public class LevenshteinDistance extends Distance {
84 84 * @see
85 85 * mtas.codec.util.distance.Distance#validate(org.apache.lucene.util.BytesRef)
86 86 */
87   - public boolean validate(BytesRef term) {
  87 + public boolean validateMaximum(BytesRef term) {
88 88 if (maximum == null) {
89 89 return true;
90 90 } else {
91 91 double[][] state = _start();
92 92 char ch1;
93   - int i = term.offset + MtasToken.DELIMITER.length() + prefix.length();
  93 + int i = term.offset + prefixOffset;
94 94 for (; i < term.length; i++) {
95 95 ch1 = (char) term.bytes[i];
96 96 if (ch1 == 0x00) {
... ... @@ -104,7 +104,31 @@ public class LevenshteinDistance extends Distance {
104 104 return _is_match(state);
105 105 }
106 106 }
107   -
  107 +
  108 + @Override
  109 + public boolean validateMinimum(BytesRef term) {
  110 + if (minimum == null) {
  111 + return true;
  112 + } else {
  113 + return compute(term)>minimum;
  114 + }
  115 + }
  116 +
  117 + @Override
  118 + public double compute(BytesRef term) {
  119 + double[][] state = _start();
  120 + char ch1;
  121 + int i = term.offset + prefixOffset;
  122 + for (; i < term.length; i++) {
  123 + ch1 = (char) term.bytes[i];
  124 + if (ch1 == 0x00) {
  125 + break;
  126 + }
  127 + state = _step(state, ch1);
  128 + }
  129 + return _distance(state);
  130 + }
  131 +
108 132 /*
109 133 * (non-Javadoc)
110 134 *
... ... @@ -173,7 +197,7 @@ public class LevenshteinDistance extends Distance {
173 197 * @return true, if successful
174 198 */
175 199 private boolean _is_match(double[][] state) {
176   - return state[1][state[1].length - 1] <= maximum;
  200 + return state[1][state[1].length - 1] < maximum;
177 201 }
178 202  
179 203 /**
... ... @@ -184,7 +208,7 @@ public class LevenshteinDistance extends Distance {
184 208 */
185 209 private boolean _can_match(double[][] state) {
186 210 for (double d : state[1]) {
187   - if (d <= maximum) {
  211 + if (d < maximum) {
188 212 return true;
189 213 }
190 214 }
... ...
src/main/java/mtas/solr/handler/MtasRequestHandler.java
... ... @@ -9,10 +9,18 @@ import java.util.ArrayList;
9 9 import java.util.HashMap;
10 10 import java.util.Iterator;
11 11 import java.util.Map;
  12 +import java.util.Objects;
12 13  
13 14 import org.apache.commons.io.IOUtils;
14 15 import org.apache.commons.logging.Log;
15 16 import org.apache.commons.logging.LogFactory;
  17 +import org.apache.solr.client.solrj.SolrClient;
  18 +import org.apache.solr.client.solrj.SolrServerException;
  19 +import org.apache.solr.client.solrj.impl.HttpSolrClient;
  20 +import org.apache.solr.client.solrj.response.QueryResponse;
  21 +import org.apache.solr.common.params.CommonParams;
  22 +import org.apache.solr.common.params.ModifiableSolrParams;
  23 +import org.apache.solr.common.params.ShardParams;
16 24 import org.apache.solr.common.util.ContentStream;
17 25 import org.apache.solr.handler.RequestHandlerBase;
18 26 import org.apache.solr.request.SolrQueryRequest;
... ... @@ -23,6 +31,11 @@ import org.noggit.ObjectBuilder;
23 31 import mtas.analysis.MtasTokenizer;
24 32 import mtas.analysis.util.MtasFetchData;
25 33 import mtas.analysis.util.MtasParserException;
  34 +import mtas.solr.handler.component.MtasSolrSearchComponent;
  35 +import mtas.solr.handler.component.util.MtasSolrComponentStatus;
  36 +import mtas.solr.handler.util.MtasSolrHistoryList;
  37 +import mtas.solr.handler.util.MtasSolrRunningList;
  38 +import mtas.solr.handler.util.MtasSolrStatus;
26 39  
27 40 /**
28 41 * The Class MtasRequestHandler.
... ... @@ -32,32 +45,80 @@ public class MtasRequestHandler extends RequestHandlerBase {
32 45 /** The log. */
33 46 private static Log log = LogFactory.getLog(MtasRequestHandler.class);
34 47  
35   - /** The Constant ERROR. */
36   - private static final String ERROR = "error";
  48 + /** The Constant MESSAGE_ERROR. */
  49 + public static final String MESSAGE_ERROR = "error";
37 50  
38 51 /** The Constant ACTION_CONFIG_FILES. */
39   - private static final String ACTION_CONFIG_FILES = "files";
  52 + public static final String ACTION_CONFIG_FILES = "files";
40 53  
41 54 /** The Constant ACTION_CONFIG_FILE. */
42   - private static final String ACTION_CONFIG_FILE = "file";
  55 + public static final String ACTION_CONFIG_FILE = "file";
43 56  
44 57 /** The Constant ACTION_MAPPING. */
45   - private static final String ACTION_MAPPING = "mapping";
  58 + public static final String ACTION_MAPPING = "mapping";
  59 +
  60 + /** The Constant ACTION_RUNNING. */
  61 + public static final String ACTION_RUNNING = "running";
  62 +
  63 + /** The Constant ACTION_HISTORY. */
  64 + public static final String ACTION_HISTORY = "history";
  65 +
  66 + /** The Constant ACTION_ERROR. */
  67 + public static final String ACTION_ERROR = "error";
  68 +
  69 + /** The Constant ACTION_STATUS. */
  70 + public static final String ACTION_STATUS = "status";
46 71  
47 72 /** The Constant PARAM_ACTION. */
48   - private static final String PARAM_ACTION = "action";
  73 + public static final String PARAM_ACTION = "action";
  74 +
  75 + /** The Constant PARAM_KEY. */
  76 + public static final String PARAM_KEY = "key";
  77 +
  78 + /** The Constant PARAM_ABORT. */
  79 + public static final String PARAM_ABORT = "abort";
  80 +
  81 + /** The Constant PARAM_SHARDREQUESTS. */
  82 + public static final String PARAM_SHARDREQUESTS = "shardRequests";
49 83  
50 84 /** The Constant PARAM_CONFIG_FILE. */
51   - private static final String PARAM_CONFIG_FILE = "file";
  85 + public static final String PARAM_CONFIG_FILE = "file";
52 86  
53 87 /** The Constant PARAM_MAPPING_CONFIGURATION. */
54   - private static final String PARAM_MAPPING_CONFIGURATION = "configuration";
  88 + public static final String PARAM_MAPPING_CONFIGURATION = "configuration";
55 89  
56 90 /** The Constant PARAM_MAPPING_DOCUMENT. */
57   - private static final String PARAM_MAPPING_DOCUMENT = "document";
  91 + public static final String PARAM_MAPPING_DOCUMENT = "document";
58 92  
59 93 /** The Constant PARAM_MAPPING_DOCUMENT_URL. */
60   - private static final String PARAM_MAPPING_DOCUMENT_URL = "url";
  94 + public static final String PARAM_MAPPING_DOCUMENT_URL = "url";
  95 +
  96 + /** The running. */
  97 + private MtasSolrRunningList running;
  98 +
  99 + /** The history. */
  100 + private MtasSolrHistoryList history;
  101 +
  102 + /** The error. */
  103 + private MtasSolrHistoryList error;
  104 +
  105 + /** The shard index. */
  106 + private Map<String, ShardInformation> shardIndex;
  107 +
  108 + private static final int defaultTimeout = 3600;
  109 + private static final int defaultSoftLimit = 100;
  110 + private static final int defaultHardLimit = 200;
  111 +
  112 + /**
  113 + * Instantiates a new mtas request handler.
  114 + */
  115 + public MtasRequestHandler() {
  116 + super();
  117 + running = new MtasSolrRunningList(defaultTimeout);
  118 + history = new MtasSolrHistoryList(defaultSoftLimit, defaultHardLimit);
  119 + error = new MtasSolrHistoryList(defaultSoftLimit, defaultHardLimit);
  120 + shardIndex = new HashMap<>();
  121 + }
61 122  
62 123 /*
63 124 * (non-Javadoc)
... ... @@ -68,76 +129,101 @@ public class MtasRequestHandler extends RequestHandlerBase {
68 129 */
69 130 @Override
70 131 public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
71   - throws IOException {
72   -
73   - String configDir = req.getCore().getResourceLoader().getConfigDir();
74   - // generate list of files
75   - if (req.getParams().get(PARAM_ACTION, "false")
76   - .equals(ACTION_CONFIG_FILES)) {
77   - rsp.add(ACTION_CONFIG_FILES, getFiles(configDir, null));
78   - // get file
79   - } else if (req.getParams().get(PARAM_ACTION, "false")
80   - .equals(ACTION_CONFIG_FILE)) {
81   - String file = req.getParams().get(PARAM_CONFIG_FILE, null);
82   - if (file != null && !file.contains("..")) {
83   - InputStream is;
84   - try {
85   - is = req.getCore().getResourceLoader().openResource(file);
86   - rsp.add(ACTION_CONFIG_FILE,
87   - IOUtils.toString(is, StandardCharsets.UTF_8));
88   - } catch (IOException e) {
89   - log.debug(e);
90   - rsp.add(ERROR, e.getMessage());
  132 + throws IOException {
  133 + String action;
  134 + if ((action = req.getParams().get(PARAM_ACTION)) != null) {
  135 + // generate list of files
  136 + if (action.equals(ACTION_CONFIG_FILES)) {
  137 + String configDir = req.getCore().getResourceLoader().getConfigDir();
  138 + rsp.add(ACTION_CONFIG_FILES, getFiles(configDir, null));
  139 + // get file
  140 + } else if (action.equals(ACTION_CONFIG_FILE)) {
  141 + String file = req.getParams().get(PARAM_CONFIG_FILE, null);
  142 + if (file != null && !file.contains("..") && !file.startsWith("/")) {
  143 + InputStream is;
  144 + try {
  145 + is = req.getCore().getResourceLoader().openResource(file);
  146 + rsp.add(ACTION_CONFIG_FILE,
  147 + IOUtils.toString(is, StandardCharsets.UTF_8));
  148 + } catch (IOException e) {
  149 + log.debug(e);
  150 + rsp.add(MESSAGE_ERROR, e.getMessage());
  151 + }
91 152 }
92   - }
93   - // test mapping
94   - } else if (req.getParams().get(PARAM_ACTION, "false")
95   - .equals(ACTION_MAPPING)) {
96   - String configuration = null;
97   - String document = null;
98   - String documentUrl = null;
99   - if (req.getContentStreams() != null) {
100   - Iterator<ContentStream> it = req.getContentStreams().iterator();
101   - if (it.hasNext()) {
102   - ContentStream cs = it.next();
103   - Map<String, String> params = new HashMap<>();
104   - getParamsFromJSON(params, IOUtils.toString(cs.getReader()));
105   - configuration = params.get(PARAM_MAPPING_CONFIGURATION);
106   - document = params.get(PARAM_MAPPING_DOCUMENT);
107   - documentUrl = params.get(PARAM_MAPPING_DOCUMENT_URL);
  153 + // test mapping
  154 + } else if (action.equals(ACTION_MAPPING)) {
  155 + String configuration = null;
  156 + String document = null;
  157 + String documentUrl = null;
  158 + if (req.getContentStreams() != null) {
  159 + Iterator<ContentStream> it = req.getContentStreams().iterator();
  160 + if (it.hasNext()) {
  161 + ContentStream cs = it.next();
  162 + Map<String, String> params = new HashMap<>();
  163 + getParamsFromJSON(params, IOUtils.toString(cs.getReader()));
  164 + configuration = params.get(PARAM_MAPPING_CONFIGURATION);
  165 + document = params.get(PARAM_MAPPING_DOCUMENT);
  166 + documentUrl = params.get(PARAM_MAPPING_DOCUMENT_URL);
  167 + }
  168 + } else {
  169 + configuration = req.getParams().get(PARAM_MAPPING_CONFIGURATION);
  170 + document = req.getParams().get(PARAM_MAPPING_DOCUMENT);
  171 + documentUrl = req.getParams().get(PARAM_MAPPING_DOCUMENT_URL);
108 172 }
109   - } else {
110   - configuration = req.getParams().get(PARAM_MAPPING_CONFIGURATION);
111   - document = req.getParams().get(PARAM_MAPPING_DOCUMENT);
112   - documentUrl = req.getParams().get(PARAM_MAPPING_DOCUMENT_URL);
113   - }
114   - if (configuration != null && documentUrl != null) {
115   - InputStream stream = IOUtils.toInputStream(configuration,
116   - StandardCharsets.UTF_8);
117   - try (MtasTokenizer tokenizer = new MtasTokenizer(stream);) {
118   - MtasFetchData fetchData = new MtasFetchData(
119   - new StringReader(documentUrl));
120   - rsp.add(ACTION_MAPPING,
121   - tokenizer.getList(fetchData.getUrl(null, null)));
122   - tokenizer.close();
123   - } catch (IOException | MtasParserException e) {
124   - log.debug(e);
125   - rsp.add(ERROR, e.getMessage());
126   - } finally {
127   - stream.close();
  173 + if (configuration != null && documentUrl != null) {
  174 + InputStream stream = IOUtils.toInputStream(configuration,
  175 + StandardCharsets.UTF_8);
  176 + try (MtasTokenizer tokenizer = new MtasTokenizer(stream);) {
  177 + MtasFetchData fetchData = new MtasFetchData(
  178 + new StringReader(documentUrl));
  179 + rsp.add(ACTION_MAPPING,
  180 + tokenizer.getList(fetchData.getUrl(null, null)));
  181 + tokenizer.close();
  182 + } catch (IOException | MtasParserException e) {
  183 + log.debug(e);
  184 + rsp.add(MESSAGE_ERROR, e.getMessage());
  185 + } finally {
  186 + stream.close();
  187 + }
  188 + } else if (configuration != null && document != null) {
  189 + InputStream stream = IOUtils.toInputStream(configuration,
  190 + StandardCharsets.UTF_8);
  191 + try (MtasTokenizer tokenizer = new MtasTokenizer(stream);) {
  192 + rsp.add(ACTION_MAPPING,
  193 + tokenizer.getList(new StringReader(document)));
  194 + tokenizer.close();
  195 + } catch (IOException e) {
  196 + log.debug(e);
  197 + rsp.add(MESSAGE_ERROR, e.getMessage());
  198 + } finally {
  199 + stream.close();
  200 + }
128 201 }
129   - } else if (configuration != null && document != null) {
130   - InputStream stream = IOUtils.toInputStream(configuration,
131   - StandardCharsets.UTF_8);
132   - try (MtasTokenizer tokenizer = new MtasTokenizer(stream);) {
133   - rsp.add(ACTION_MAPPING,
134   - tokenizer.getList(new StringReader(document)));
135   - tokenizer.close();
136   - } catch (IOException e) {
137   - log.debug(e);
138   - rsp.add(ERROR, e.getMessage());
139   - } finally {
140   - stream.close();
  202 + } else if (action.equals(ACTION_RUNNING)) {
  203 + boolean shardRequests = req.getParams().getBool(PARAM_SHARDREQUESTS,
  204 + false);
  205 + rsp.add(ACTION_RUNNING, running.createOutput(shardRequests));
  206 + } else if (action.equals(ACTION_HISTORY)) {
  207 + boolean shardRequests = req.getParams().getBool(PARAM_SHARDREQUESTS,
  208 + false);
  209 + rsp.add(ACTION_HISTORY, history.createOutput(shardRequests));
  210 + } else if (action.equals(ACTION_ERROR)) {
  211 + boolean shardRequests = req.getParams().getBool(PARAM_SHARDREQUESTS,
  212 + false);
  213 + rsp.add(ACTION_ERROR, error.createOutput(shardRequests));
  214 + } else if (action.equals(ACTION_STATUS)) {
  215 + String key = req.getParams().get(PARAM_KEY, null);
  216 + String abort = req.getParams().get(PARAM_ABORT, null);
  217 + MtasSolrStatus solrStatus = null;
  218 + if ((solrStatus = history.get(key)) != null
  219 + || (solrStatus = running.get(key)) != null
  220 + || (solrStatus = error.get(key)) != null) {
  221 + if (abort != null && !solrStatus.finished()) {
  222 + solrStatus.setError(abort);
  223 + }
  224 + rsp.add(ACTION_STATUS, solrStatus.createOutput());
  225 + } else {
  226 + rsp.add(ACTION_STATUS, null);
141 227 }
142 228 }
143 229 }
... ... @@ -205,7 +291,6 @@ public class MtasRequestHandler extends RequestHandlerBase {
205 291 if (params.get(key) != null) {
206 292 continue;
207 293 }
208   -
209 294 if (val == null) {
210 295 params.remove(key);
211 296 } else if (val instanceof String) {
... ... @@ -220,4 +305,150 @@ public class MtasRequestHandler extends RequestHandlerBase {
220 305 }
221 306 }
222 307  
  308 + /**
  309 + * Register status.
  310 + *
  311 + * @param item the item
  312 + * @throws IOException Signals that an I/O exception has occurred.
  313 + */
  314 + public void registerStatus(MtasSolrStatus item) throws IOException {
  315 + history.add(item);
  316 + running.add(item);
  317 + }
  318 +
  319 + /**
  320 + * Finish status.
  321 + *
  322 + * @param item the item
  323 + * @throws IOException Signals that an I/O exception has occurred.
  324 + */
  325 + public void finishStatus(MtasSolrStatus item) throws IOException {
  326 + running.remove(item);
  327 + if (item.error()) {
  328 + error.add(item);
  329 + }
  330 + }
  331 +
  332 + /**
  333 + * Check key.
  334 + *
  335 + * @param key the key
  336 + * @throws IOException Signals that an I/O exception has occurred.
  337 + */
  338 + public void checkKey(String key) throws IOException {
  339 + history.updateKey(key);
  340 + }
  341 +
  342 + /**
  343 + * Gets the shard information.
  344 + *
  345 + * @param shard the shard
  346 + * @return the shard information
  347 + */
  348 + public ShardInformation getShardInformation(String shard) {
  349 + ShardInformation shardInformation = shardIndex
  350 + .get(Objects.requireNonNull(shard, "shard required"));
  351 + if (shardInformation == null) {
  352 + shardInformation = createShardInformation(shard);
  353 + }
  354 + return shardInformation;
  355 + }
  356 +
  357 + /**
  358 + * Creates the shard information.
  359 + *
  360 + * @param shard the shard
  361 + * @return the shard information
  362 + */
  363 + private ShardInformation createShardInformation(String shard) {
  364 + ShardInformation shardInformation = new ShardInformation(shard);
  365 + SolrClient solrClient = new HttpSolrClient.Builder(shard).build();
  366 + ModifiableSolrParams solrParams = new ModifiableSolrParams();
  367 + solrParams.add(CommonParams.Q, "*:*");
  368 + solrParams.add(CommonParams.ROWS, "0");
  369 + solrParams.add(CommonParams.HEADER_ECHO_PARAMS, "none");
  370 + solrParams.add(ShardParams.IS_SHARD, CommonParams.TRUE);
  371 + solrParams.add(MtasSolrSearchComponent.PARAM_MTAS, CommonParams.TRUE);
  372 + solrParams.add(MtasSolrComponentStatus.PARAM_MTAS_STATUS,
  373 + CommonParams.TRUE);
  374 + solrParams.add(
  375 + MtasSolrComponentStatus.PARAM_MTAS_STATUS + "."
  376 + + MtasSolrComponentStatus.NAME_MTAS_STATUS_MTASHANDLER,
  377 + CommonParams.TRUE);
  378 + solrParams.add(
  379 + MtasSolrComponentStatus.PARAM_MTAS_STATUS + "."
  380 + + MtasSolrComponentStatus.NAME_MTAS_STATUS_NUMBEROFSEGMENTS,
  381 + CommonParams.TRUE);
  382 + solrParams.add(
  383 + MtasSolrComponentStatus.PARAM_MTAS_STATUS + "."
  384 + + MtasSolrComponentStatus.NAME_MTAS_STATUS_NUMBEROFDOCUMENTS,
  385 + CommonParams.TRUE);
  386 + try {
  387 + QueryResponse response = solrClient.query(solrParams);
  388 + Object mtasHandlerObject = Objects.requireNonNull(response.getResponse().findRecursive(
  389 + MtasSolrSearchComponent.NAME, MtasSolrComponentStatus.NAME,
  390 + MtasSolrComponentStatus.NAME_MTAS_STATUS_MTASHANDLER), "no number of segments for "+shard);
  391 + Object numberOfSegmentsObject = Objects.requireNonNull(response.getResponse().findRecursive(
  392 + MtasSolrSearchComponent.NAME, MtasSolrComponentStatus.NAME,
  393 + MtasSolrComponentStatus.NAME_MTAS_STATUS_NUMBEROFSEGMENTS), "no number of documents for "+shard);
  394 + Object numberOfDocumentsObject = Objects.requireNonNull(response.getResponse().findRecursive(
  395 + MtasSolrSearchComponent.NAME, MtasSolrComponentStatus.NAME,
  396 + MtasSolrComponentStatus.NAME_MTAS_STATUS_NUMBEROFDOCUMENTS), "no name for "+shard);
  397 + Object nameObject = Objects.requireNonNull(response.getResponse().findRecursive(
  398 + MtasSolrSearchComponent.NAME, MtasSolrComponentStatus.NAME,
  399 + ShardInformation.NAME_NAME), "no handler for "+shard);
  400 + if (mtasHandlerObject instanceof String) {
  401 + shardInformation.mtasHandler = (String) mtasHandlerObject;
  402 + }
  403 + if (numberOfSegmentsObject instanceof Integer) {
  404 + shardInformation.numberOfSegments = (Integer) numberOfSegmentsObject;
  405 + }
  406 + if (numberOfDocumentsObject instanceof Integer) {
  407 + shardInformation.numberOfDocuments = ((Integer) numberOfDocumentsObject)
  408 + .longValue();
  409 + }
  410 + if (nameObject instanceof String) {
  411 + shardInformation.name = (String) nameObject;
  412 + }
  413 + shardIndex.put(shard, shardInformation);
  414 + } catch (NullPointerException | SolrServerException | IOException e) {
  415 + log.error(e);
  416 + return null;
  417 + }
  418 + return shardInformation;
  419 + }
  420 +
  421 + /**
  422 + * The Class ShardInformation.
  423 + */
  424 + public class ShardInformation {
  425 +
  426 + /** The Constant NAME_NAME. */
  427 + public final static String NAME_NAME = "name";
  428 +
  429 + /** The number of documents. */
  430 + public Long numberOfDocuments = null;
  431 +
  432 + /** The number of segments. */
  433 + public Integer numberOfSegments = null;
  434 +
  435 + /** The mtas handler. */
  436 + public String mtasHandler = null;
  437 +
  438 + /** The name. */
  439 + public String name = null;
  440 +
  441 + /** The location. */
  442 + public String location;
  443 +
  444 + /**
  445 + * Instantiates a new shard information.
  446 + *
  447 + * @param location the location
  448 + */
  449 + public ShardInformation(String location) {
  450 + this.location = location;
  451 + }
  452 + }
  453 +
223 454 }
... ...
src/main/java/mtas/solr/handler/component/MtasSolrSearchComponent.java
... ... @@ -3,8 +3,12 @@ package mtas.solr.handler.component;
3 3 import java.io.IOException;
4 4 import java.lang.reflect.InvocationTargetException;
5 5 import java.util.ArrayList;
  6 +import java.util.Arrays;
6 7 import java.util.Collections;
7 8 import java.util.Iterator;
  9 +import java.util.Map;
  10 +import java.util.Objects;
  11 +import java.util.Map.Entry;
8 12  
9 13 import mtas.codec.util.CodecComponent.ComponentDocument;
10 14 import mtas.codec.util.CodecComponent.ComponentFacet;
... ... @@ -18,24 +22,34 @@ import mtas.codec.util.CodecComponent.ComponentSpan;
18 22 import mtas.codec.util.CodecComponent.ComponentTermVector;
19 23 import mtas.codec.util.CodecComponent.ComponentToken;
20 24 import mtas.codec.util.CodecUtil;
  25 +import mtas.codec.util.Status;
21 26 import mtas.solr.handler.component.util.MtasSolrResultMerge;
  27 +import mtas.solr.handler.util.MtasSolrStatus;
  28 +import mtas.solr.handler.util.MtasSolrStatus.ShardStatus;
22 29 import mtas.solr.search.MtasSolrCollectionCache;
23 30 import mtas.solr.handler.component.util.MtasSolrComponentDocument;
24 31 import mtas.solr.handler.component.util.MtasSolrComponentFacet;
25 32 import mtas.solr.handler.component.util.MtasSolrComponentGroup;
  33 +import mtas.solr.handler.MtasRequestHandler;
  34 +import mtas.solr.handler.MtasRequestHandler.ShardInformation;
26 35 import mtas.solr.handler.component.util.MtasSolrComponentCollection;
27 36 import mtas.solr.handler.component.util.MtasSolrComponentKwic;
28 37 import mtas.solr.handler.component.util.MtasSolrComponentList;
29 38 import mtas.solr.handler.component.util.MtasSolrComponentPrefix;
30 39 import mtas.solr.handler.component.util.MtasSolrComponentStats;
  40 +import mtas.solr.handler.component.util.MtasSolrComponentStatus;
31 41 import mtas.solr.handler.component.util.MtasSolrComponentTermvector;
32 42 import org.apache.commons.logging.Log;
33 43 import org.apache.commons.logging.LogFactory;
  44 +import org.apache.solr.common.params.CommonParams;
  45 +import org.apache.solr.common.params.ShardParams;
34 46 import org.apache.solr.common.util.NamedList;
35 47 import org.apache.solr.common.util.SimpleOrderedMap;
  48 +import org.apache.solr.core.SolrInfoBean;
36 49 import org.apache.solr.handler.component.ResponseBuilder;
37 50 import org.apache.solr.handler.component.SearchComponent;
38 51 import org.apache.solr.handler.component.ShardRequest;
  52 +import org.apache.solr.response.BasicResultContext;
39 53 import org.apache.solr.search.DocList;
40 54 import org.apache.solr.search.DocSet;
41 55 import org.apache.solr.search.SolrIndexSearcher;
... ... @@ -63,6 +77,8 @@ public class MtasSolrSearchComponent extends SearchComponent {
63 77 /** The Constant CONFIG_COLLECTION_MAXIMUM_OVERFLOW. */
64 78 public static final String CONFIG_COLLECTION_MAXIMUM_OVERFLOW = "collectionMaximumOverflow";
65 79  
  80 + public static final String NAME = "mtas";
  81 +
66 82 /** The Constant PARAM_MTAS. */
67 83 public static final String PARAM_MTAS = "mtas";
68 84  
... ... @@ -139,9 +155,17 @@ public class MtasSolrSearchComponent extends SearchComponent {
139 155 /** The search collection. */
140 156 private MtasSolrComponentCollection searchCollection;
141 157  
  158 + /** The search status. */
  159 + private MtasSolrComponentStatus searchStatus;
  160 +
142 161 /** The collection cache. */
143 162 private MtasSolrCollectionCache collectionCache = null;
144 163  
  164 + /** The request handler. */
  165 + private MtasRequestHandler requestHandler = null;
  166 +
  167 + private String requestHandlerName = null;
  168 +
145 169 /*
146 170 * (non-Javadoc)
147 171 *
... ... @@ -151,8 +175,9 @@ public class MtasSolrSearchComponent extends SearchComponent {
151 175 */
152 176 @Override
153 177 public void init(NamedList args) {
154   - super.init(args);
  178 + super.init(args);
155 179 // init components
  180 + searchStatus = new MtasSolrComponentStatus(this);
156 181 searchDocument = new MtasSolrComponentDocument(this);
157 182 searchKwic = new MtasSolrComponentKwic(this);
158 183 searchList = new MtasSolrComponentList(this);
... ... @@ -218,59 +243,90 @@ public class MtasSolrSearchComponent extends SearchComponent {
218 243 */
219 244 @Override
220 245 public void prepare(ResponseBuilder rb) throws IOException {
221   - //System.out
222   - //.println(System.nanoTime() + " - " + Thread.currentThread().getId()
223   - //+ " - " + rb.req.getParams().getBool("isShard", false) + " PREPARE "
224   - //+ rb.stage + " " + rb.req.getParamString());
  246 + // System.out
  247 + // .println(System.nanoTime() + " - " + Thread.currentThread().getId()
  248 + // + " - " + rb.req.getParams().getBool(ShardParams.IS_SHARD, false)
  249 + // + " PREPARE " + rb.stage + " " + rb.req.getParamString());
  250 + // always create status
  251 + initializeRequestHandler(rb);
  252 + MtasSolrStatus solrStatus = new MtasSolrStatus(
  253 + rb.req.getOriginalParams().toQueryString(),
  254 + rb.req.getParams().getBool(ShardParams.IS_SHARD, false), rb.shards,
  255 + rb.rsp);
  256 + rb.req.getContext().put(MtasSolrStatus.class, solrStatus);
  257 + solrStatus.setStage(rb.stage);
225 258 if (rb.req.getParams().getBool(PARAM_MTAS, false)) {
226   - mtasSolrResultMerge = new MtasSolrResultMerge();
227   - ComponentFields mtasFields = new ComponentFields();
228   - // get settings document
229   - if (rb.req.getParams()
230   - .getBool(MtasSolrComponentDocument.PARAM_MTAS_DOCUMENT, false)) {
231   - searchDocument.prepare(rb, mtasFields);
232   - }
233   - // get settings kwic
234   - if (rb.req.getParams().getBool(MtasSolrComponentKwic.PARAM_MTAS_KWIC,
235   - false)) {
236   - searchKwic.prepare(rb, mtasFields);
237   - }
238   - // get settings list
239   - if (rb.req.getParams().getBool(MtasSolrComponentList.PARAM_MTAS_LIST,
240   - false)) {
241   - searchList.prepare(rb, mtasFields);
242   - }
243   - // get settings group
244   - if (rb.req.getParams().getBool(MtasSolrComponentGroup.PARAM_MTAS_GROUP,
245   - false)) {
246   - searchGroup.prepare(rb, mtasFields);
247   - }
248   - // get settings termvector
249   - if (rb.req.getParams()
250   - .getBool(MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {
251   - searchTermvector.prepare(rb, mtasFields);
252   - }
253   - // get settings prefix
254   - if (rb.req.getParams().getBool(MtasSolrComponentPrefix.PARAM_MTAS_PREFIX,
255   - false)) {
256   - searchPrefix.prepare(rb, mtasFields);
257   - }
258   - // get settings stats
259   - if (rb.req.getParams().getBool(MtasSolrComponentStats.PARAM_MTAS_STATS,
260   - false)) {
261   - searchStats.prepare(rb, mtasFields);
262   - }
263   - // get settings facet
264   - if (rb.req.getParams().getBool(MtasSolrComponentFacet.PARAM_MTAS_FACET,
265   - false)) {
266   - searchFacet.prepare(rb, mtasFields);
267   - }
268   - // get settings collection
269   - if (rb.req.getParams()
270   - .getBool(MtasSolrComponentCollection.PARAM_MTAS_COLLECTION, false)) {
271   - searchCollection.prepare(rb, mtasFields);
  259 + try {
  260 + // initialize
  261 + mtasSolrResultMerge = new MtasSolrResultMerge();
  262 + // prepare components
  263 + ComponentFields mtasFields = new ComponentFields();
  264 + // get settings status
  265 + if (rb.req.getParams()
  266 + .getBool(MtasSolrComponentStatus.PARAM_MTAS_STATUS, false)) {
  267 + searchStatus.prepare(rb, mtasFields);
  268 + mtasFields.status.handler = requestHandlerName;
  269 + if (mtasFields.status.key != null) {
  270 + solrStatus.setKey(mtasFields.status.key);
  271 + }
  272 + }
  273 + // now, register status
  274 + registerStatus(solrStatus);
  275 + // get settings document
  276 + if (rb.req.getParams()
  277 + .getBool(MtasSolrComponentDocument.PARAM_MTAS_DOCUMENT, false)) {
  278 + searchDocument.prepare(rb, mtasFields);
  279 + }
  280 + // get settings kwic
  281 + if (rb.req.getParams().getBool(MtasSolrComponentKwic.PARAM_MTAS_KWIC,
  282 + false)) {
  283 + searchKwic.prepare(rb, mtasFields);
  284 + }
  285 + // get settings list
  286 + if (rb.req.getParams().getBool(MtasSolrComponentList.PARAM_MTAS_LIST,
  287 + false)) {
  288 + searchList.prepare(rb, mtasFields);
  289 + }
  290 + // get settings group
  291 + if (rb.req.getParams().getBool(MtasSolrComponentGroup.PARAM_MTAS_GROUP,
  292 + false)) {
  293 + searchGroup.prepare(rb, mtasFields);
  294 + }
  295 + // get settings termvector
  296 + if (rb.req.getParams().getBool(
  297 + MtasSolrComponentTermvector.PARAM_MTAS_TERMVECTOR, false)) {
  298 + searchTermvector.prepare(rb, mtasFields);
  299 + }
  300 + // get settings prefix
  301 + if (rb.req.getParams()
  302 + .getBool(MtasSolrComponentPrefix.PARAM_MTAS_PREFIX, false)) {
  303 + searchPrefix.prepare(rb, mtasFields);
  304 + }
  305 + // get settings stats
  306 + if (rb.req.getParams().getBool(MtasSolrComponentStats.PARAM_MTAS_STATS,
  307 + false)) {
  308 + searchStats.prepare(rb, mtasFields);
  309 + }
  310 + // get settings facet
  311 + if (rb.req.getParams().getBool(MtasSolrComponentFacet.PARAM_MTAS_FACET,
  312 + false)) {
  313 + searchFacet.prepare(rb, mtasFields);
  314 + }
  315 + // get settings collection
  316 + if (rb.req.getParams().getBool(
  317 + MtasSolrComponentCollection.PARAM_MTAS_COLLECTION, false)) {
  318 + searchCollection.prepare(rb, mtasFields);
  319 + }
  320 + rb.req.getContext().put(ComponentFields.class, mtasFields);
  321 + } catch (IOException e) {
  322 + solrStatus.setError(e);
  323 + } finally {
  324 + checkStatus(solrStatus);
272 325 }
273   - rb.req.getContext().put(ComponentFields.class, mtasFields);
  326 + } else {
  327 + // register and check status
  328 + registerStatus(solrStatus);
  329 + checkStatus(solrStatus);
274 330 }
275 331 }
276 332  
... ... @@ -285,213 +341,283 @@ public class MtasSolrSearchComponent extends SearchComponent {
285 341 public void process(ResponseBuilder rb) throws IOException {
286 342 // System.out
287 343 // .println(System.nanoTime() + " - " + Thread.currentThread().getId()
288   - // + " - " + rb.req.getParams().getBool("isShard", false) + " PROCESS "
289   - // + rb.stage + " " + rb.req.getParamString());
290   - ComponentFields mtasFields = getMtasFields(rb);
291   - if (mtasFields != null) {
292   - DocSet docSet = rb.getResults().docSet;
293   - DocList docList = rb.getResults().docList;
294   - if (mtasFields.doStats || mtasFields.doDocument || mtasFields.doKwic
295   - || mtasFields.doList || mtasFields.doGroup || mtasFields.doFacet
296   - || mtasFields.doCollection || mtasFields.doTermVector
297   - || mtasFields.doPrefix) {
298   - SolrIndexSearcher searcher = rb.req.getSearcher();
299   - ArrayList<Integer> docSetList = null;
300   - ArrayList<Integer> docListList = null;
301   - if (docSet != null) {
302   - docSetList = new ArrayList<>();
303   - Iterator<Integer> docSetIterator = docSet.iterator();
304   - while (docSetIterator.hasNext()) {
305   - docSetList.add(docSetIterator.next());
306   - }
307   - Collections.sort(docSetList);
308   - }
309   - if (docList != null) {
310   - docListList = new ArrayList<>();
311   - Iterator<Integer> docListIterator = docList.iterator();
312   - while (docListIterator.hasNext()) {
313   - docListList.add(docListIterator.next());
314   - }
315   - Collections.sort(docListList);
316   - }
317   - for (String field : mtasFields.list.keySet()) {
318   - try {
319   - CodecUtil.collectField(field, searcher, searcher.getRawReader(),
320   - docListList, docSetList, mtasFields.list.get(field));
321   - } catch (IllegalAccessException | IllegalArgumentException
322   - | InvocationTargetException e) {
323   - log.error(e);
324   - throw new IOException(e);
325   - }
326   - }
327   - for (ComponentCollection collection : mtasFields.collection) {
328   - CodecUtil.collectCollection(searcher.getRawReader(), docSetList,
329   - collection);
330   - }
331   - NamedList<Object> mtasResponse = new SimpleOrderedMap<>();
332   - if (mtasFields.doDocument) {
333   - ArrayList<NamedList<?>> mtasDocumentResponses = new ArrayList<>();
334   - for (String field : mtasFields.list.keySet()) {
335   - for (ComponentDocument document : mtasFields.list
336   - .get(field).documentList) {
337   - mtasDocumentResponses.add(searchDocument.create(document, false));
338   - }
339   - }
340   - // add to response
341   - mtasResponse.add("document", mtasDocumentResponses);
342   - }
343   - if (mtasFields.doKwic) {
344   - ArrayList<NamedList<?>> mtasKwicResponses = new ArrayList<>();
345   - for (String field : mtasFields.list.keySet()) {
346   - for (ComponentKwic kwic : mtasFields.list.get(field).kwicList) {
347   - mtasKwicResponses.add(searchKwic.create(kwic, false));
348   - }
349   - }
350   - // add to response
351   - mtasResponse.add("kwic", mtasKwicResponses);
352   - }
353   - if (mtasFields.doFacet) {
354   - ArrayList<NamedList<?>> mtasFacetResponses = new ArrayList<>();
355   - for (String field : mtasFields.list.keySet()) {
356   - for (ComponentFacet facet : mtasFields.list.get(field).facetList) {
357   - if (rb.req.getParams().getBool("isShard", false)) {
358   - mtasFacetResponses.add(searchFacet.create(facet, true));
359   - } else {
360   - mtasFacetResponses.add(searchFacet.create(facet, false));
  344 + // + " - " + rb.req.getParams().getBool(ShardParams.IS_SHARD, false)
  345 + // + " PROCESS " + rb.stage + " " + rb.req.getParamString());
  346 + MtasSolrStatus solrStatus = Objects.requireNonNull(
  347 + (MtasSolrStatus) rb.req.getContext().get(MtasSolrStatus.class),
  348 + "couldn't find status");
  349 + solrStatus.setStage(rb.stage);
  350 + try {
  351 + if (rb.req.getParams().getBool(PARAM_MTAS, false)) {
  352 + try {
  353 + ComponentFields mtasFields = getMtasFields(rb);
  354 + if (mtasFields != null) {
  355 + DocSet docSet = rb.getResults().docSet;
  356 + DocList docList = rb.getResults().docList;
  357 + if (mtasFields.doStats || mtasFields.doDocument || mtasFields.doKwic
  358 + || mtasFields.doList || mtasFields.doGroup || mtasFields.doFacet
  359 + || mtasFields.doCollection || mtasFields.doTermVector
  360 + || mtasFields.doPrefix || mtasFields.doStatus) {
  361 + SolrIndexSearcher searcher = rb.req.getSearcher();
  362 + ArrayList<Integer> docSetList = null;
  363 + ArrayList<Integer> docListList = null;
  364 + // initialise docSetList
  365 + if (docSet != null) {
  366 + docSetList = new ArrayList<>();
  367 + Iterator<Integer> docSetIterator = docSet.iterator();
  368 + while (docSetIterator.hasNext()) {
  369 + docSetList.add(docSetIterator.next());
  370 + }
  371 + Collections.sort(docSetList);
361 372 }
362   - }
363   - }
364   - // add to response
365   - mtasResponse.add("facet", mtasFacetResponses);
366   - }
367   - if (mtasFields.doCollection) {
368   - ArrayList<NamedList<?>> mtasCollectionResponses = new ArrayList<>();
369   - for (ComponentCollection collection : mtasFields.collection) {
370   - if (rb.req.getParams().getBool("isShard", false)) {
371   - mtasCollectionResponses
372   - .add(searchCollection.create(collection, true));
373   - } else {
374   - mtasCollectionResponses
375   - .add(searchCollection.create(collection, false));
376   - }
377   - }
378   - // add to response
379   - mtasResponse.add("collection", mtasCollectionResponses);
380   - }
381   - if (mtasFields.doList) {
382   - ArrayList<NamedList<?>> mtasListResponses = new ArrayList<>();
383   - for (String field : mtasFields.list.keySet()) {
384   - for (ComponentList list : mtasFields.list.get(field).listList) {
385   - mtasListResponses.add(searchList.create(list, false));
386   - }
387   - }
388   - // add to response
389   - mtasResponse.add("list", mtasListResponses);
390   - }
391   - if (mtasFields.doGroup) {
392   - ArrayList<NamedList<?>> mtasGroupResponses = new ArrayList<>();
393   - for (String field : mtasFields.list.keySet()) {
394   - for (ComponentGroup group : mtasFields.list.get(field).groupList) {
395   - if (rb.req.getParams().getBool("isShard", false)) {
396   - mtasGroupResponses.add(searchGroup.create(group, true));
397   - } else {
398   - mtasGroupResponses.add(searchGroup.create(group, false));
  373 + // initialise docListList
  374 + if (docList != null) {
  375 + docListList = new ArrayList<>();
  376 + Iterator<Integer> docListIterator = docList.iterator();
  377 + while (docListIterator.hasNext()) {
  378 + docListList.add(docListIterator.next());
  379 + }
  380 + Collections.sort(docListList);
399 381 }
400   - }
401   - }
402   - // add to response
403   - mtasResponse.add("group", mtasGroupResponses);
404   - }
405   - if (mtasFields.doTermVector) {
406   - ArrayList<NamedList<?>> mtasTermVectorResponses = new ArrayList<>();
407   - for (String field : mtasFields.list.keySet()) {
408   - for (ComponentTermVector termVector : mtasFields.list
409   - .get(field).termVectorList) {
410   - if (rb.req.getParams().getBool("isShard", false)) {
411   - mtasTermVectorResponses
412   - .add(searchTermvector.create(termVector, true));
413   - } else {
414   - mtasTermVectorResponses
415   - .add(searchTermvector.create(termVector, false));
  382 + solrStatus.status().addSubs(mtasFields.list.keySet());
  383 + for (String field : mtasFields.list.keySet()) {
  384 + try {
  385 + CodecUtil.collectField(field, searcher,
  386 + searcher.getRawReader(), docListList, docSetList,
  387 + mtasFields.list.get(field), solrStatus.status());
  388 + } catch (IllegalAccessException | IllegalArgumentException
  389 + | InvocationTargetException e) {
  390 + log.error(e);
  391 + throw new IOException(e);
  392 + }
416 393 }
417   - }
418   - }
419   - // add to response
420   - mtasResponse.add("termvector", mtasTermVectorResponses);
421   - }
422   - if (mtasFields.doPrefix) {
423   - ArrayList<NamedList<?>> mtasPrefixResponses = new ArrayList<>();
424   - for (String field : mtasFields.list.keySet()) {
425   - if (mtasFields.list.get(field).prefix != null) {
426   - if (rb.req.getParams().getBool("isShard", false)) {
427   - mtasPrefixResponses.add(searchPrefix
428   - .create(mtasFields.list.get(field).prefix, true));
429   - } else {
430   - mtasPrefixResponses.add(searchPrefix
431   - .create(mtasFields.list.get(field).prefix, false));
  394 + for (ComponentCollection collection : mtasFields.collection) {
  395 + CodecUtil.collectCollection(searcher.getRawReader(), docSetList,
  396 + collection);
432 397 }
433   - }
434   - }
435   - mtasResponse.add("prefix", mtasPrefixResponses);
436   - }
437   - if (mtasFields.doStats) {
438   - NamedList<Object> mtasStatsResponse = new SimpleOrderedMap<>();
439   - if (mtasFields.doStatsPositions || mtasFields.doStatsTokens
440   - || mtasFields.doStatsSpans) {
441   - if (mtasFields.doStatsTokens) {
442   - ArrayList<Object> mtasStatsTokensResponses = new ArrayList<>();
443   - for (String field : mtasFields.list.keySet()) {
444   - for (ComponentToken token : mtasFields.list
445   - .get(field).statsTokenList) {
446   - if (rb.req.getParams().getBool("isShard", false)) {
447   - mtasStatsTokensResponses
448   - .add(searchStats.create(token, true));
449   - } else {
450   - mtasStatsTokensResponses
451   - .add(searchStats.create(token, false));
  398 + NamedList<Object> mtasResponse = new SimpleOrderedMap<>();
  399 + if (mtasFields.doStatus) {
  400 + // add to response
  401 + SimpleOrderedMap<Object> statusResponse = searchStatus.create(mtasFields.status, false);
  402 + if(statusResponse!=null) {
  403 + mtasResponse.add(MtasSolrComponentStatus.NAME,
  404 + searchStatus.create(mtasFields.status, false));
  405 + }
  406 + }
  407 + if (mtasFields.doDocument) {
  408 + ArrayList<NamedList<?>> mtasDocumentResponses = new ArrayList<>();
  409 + for (String field : mtasFields.list.keySet()) {
  410 + for (ComponentDocument document : mtasFields.list
  411 + .get(field).documentList) {
  412 + mtasDocumentResponses
  413 + .add(searchDocument.create(document, false));
452 414 }
453 415 }
  416 + // add to response
  417 + mtasResponse.add(MtasSolrComponentDocument.NAME,
  418 + mtasDocumentResponses);
454 419 }
455   - mtasStatsResponse.add("tokens", mtasStatsTokensResponses);
456   - }
457   - if (mtasFields.doStatsPositions) {
458   - ArrayList<Object> mtasStatsPositionsResponses = new ArrayList<>();
459   - for (String field : mtasFields.list.keySet()) {
460   - for (ComponentPosition position : mtasFields.list
461   - .get(field).statsPositionList) {
462   - if (rb.req.getParams().getBool("isShard", false)) {
463   - mtasStatsPositionsResponses
464   - .add(searchStats.create(position, true));
465   - } else {
466   - mtasStatsPositionsResponses
467   - .add(searchStats.create(position, false));
  420 + if (mtasFields.doKwic) {
  421 + ArrayList<NamedList<?>> mtasKwicResponses = new ArrayList<>();
  422 + for (String field : mtasFields.list.keySet()) {
  423 + for (ComponentKwic kwic : mtasFields.list
  424 + .get(field).kwicList) {
  425 + mtasKwicResponses.add(searchKwic.create(kwic, false));
468 426 }
469 427 }
  428 + // add to response
  429 + mtasResponse.add(MtasSolrComponentKwic.NAME, mtasKwicResponses);
470 430 }
471   - mtasStatsResponse.add("positions", mtasStatsPositionsResponses);
472   - }
473   - if (mtasFields.doStatsSpans) {
474   - ArrayList<Object> mtasStatsSpansResponses = new ArrayList<>();
475   - for (String field : mtasFields.list.keySet()) {
476   - for (ComponentSpan span : mtasFields.list
477   - .get(field).statsSpanList) {
478   - if (rb.req.getParams().getBool("isShard", false)) {
479   - mtasStatsSpansResponses.add(searchStats.create(span, true));
  431 + if (mtasFields.doFacet) {
  432 + ArrayList<NamedList<?>> mtasFacetResponses = new ArrayList<>();
  433 + for (String field : mtasFields.list.keySet()) {
  434 + for (ComponentFacet facet : mtasFields.list
  435 + .get(field).facetList) {
  436 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  437 + false)) {
  438 + mtasFacetResponses.add(searchFacet.create(facet, true));
  439 + } else {
  440 + mtasFacetResponses.add(searchFacet.create(facet, false));
  441 + }
  442 + }
  443 + }
  444 + // add to response
  445 + mtasResponse.add(MtasSolrComponentFacet.NAME,
  446 + mtasFacetResponses);
  447 + }
  448 + if (mtasFields.doCollection) {
  449 + ArrayList<NamedList<?>> mtasCollectionResponses = new ArrayList<>();
  450 + for (ComponentCollection collection : mtasFields.collection) {
  451 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD, false)) {
  452 + mtasCollectionResponses
  453 + .add(searchCollection.create(collection, true));
480 454 } else {
481   - mtasStatsSpansResponses
482   - .add(searchStats.create(span, false));
  455 + mtasCollectionResponses
  456 + .add(searchCollection.create(collection, false));
483 457 }
484 458 }
  459 + // add to response
  460 + mtasResponse.add(MtasSolrComponentCollection.NAME,
  461 + mtasCollectionResponses);
485 462 }
486   - mtasStatsResponse.add("spans", mtasStatsSpansResponses);
  463 + if (mtasFields.doList) {
  464 + ArrayList<NamedList<?>> mtasListResponses = new ArrayList<>();
  465 + for (String field : mtasFields.list.keySet()) {
  466 + for (ComponentList list : mtasFields.list
  467 + .get(field).listList) {
  468 + mtasListResponses.add(searchList.create(list, false));
  469 + }
  470 + }
  471 + // add to response
  472 + mtasResponse.add(MtasSolrComponentList.NAME, mtasListResponses);
  473 + }
  474 + if (mtasFields.doGroup) {
  475 + ArrayList<NamedList<?>> mtasGroupResponses = new ArrayList<>();
  476 + for (String field : mtasFields.list.keySet()) {
  477 + for (ComponentGroup group : mtasFields.list
  478 + .get(field).groupList) {
  479 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  480 + false)) {
  481 + mtasGroupResponses.add(searchGroup.create(group, true));
  482 + } else {
  483 + mtasGroupResponses.add(searchGroup.create(group, false));
  484 + }
  485 + }
  486 + }
  487 + // add to response
  488 + mtasResponse.add(MtasSolrComponentGroup.NAME,
  489 + mtasGroupResponses);
  490 + }
  491 + if (mtasFields.doTermVector) {
  492 + ArrayList<NamedList<?>> mtasTermVectorResponses = new ArrayList<>();
  493 + for (String field : mtasFields.list.keySet()) {
  494 + for (ComponentTermVector termVector : mtasFields.list
  495 + .get(field).termVectorList) {
  496 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  497 + false)) {
  498 + mtasTermVectorResponses
  499 + .add(searchTermvector.create(termVector, true));
  500 + } else {
  501 + mtasTermVectorResponses
  502 + .add(searchTermvector.create(termVector, false));
  503 + }
  504 + }
  505 + }
  506 + // add to response
  507 + mtasResponse.add(MtasSolrComponentTermvector.NAME,
  508 + mtasTermVectorResponses);
  509 + }
  510 + if (mtasFields.doPrefix) {
  511 + ArrayList<NamedList<?>> mtasPrefixResponses = new ArrayList<>();
  512 + for (String field : mtasFields.list.keySet()) {
  513 + if (mtasFields.list.get(field).prefix != null) {
  514 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  515 + false)) {
  516 + mtasPrefixResponses.add(searchPrefix
  517 + .create(mtasFields.list.get(field).prefix, true));
  518 + } else {
  519 + mtasPrefixResponses.add(searchPrefix
  520 + .create(mtasFields.list.get(field).prefix, false));
  521 + }
  522 + }
  523 + }
  524 + mtasResponse.add(MtasSolrComponentPrefix.NAME,
  525 + mtasPrefixResponses);
  526 + }
  527 + if (mtasFields.doStats) {
  528 + NamedList<Object> mtasStatsResponse = new SimpleOrderedMap<>();
  529 + if (mtasFields.doStatsPositions || mtasFields.doStatsTokens
  530 + || mtasFields.doStatsSpans) {
  531 + if (mtasFields.doStatsTokens) {
  532 + ArrayList<Object> mtasStatsTokensResponses = new ArrayList<>();
  533 + for (String field : mtasFields.list.keySet()) {
  534 + for (ComponentToken token : mtasFields.list
  535 + .get(field).statsTokenList) {
  536 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  537 + false)) {
  538 + mtasStatsTokensResponses
  539 + .add(searchStats.create(token, true));
  540 + } else {
  541 + mtasStatsTokensResponses
  542 + .add(searchStats.create(token, false));
  543 + }
  544 + }
  545 + }
  546 + mtasStatsResponse.add(MtasSolrComponentStats.NAME_TOKENS,
  547 + mtasStatsTokensResponses);
  548 + }
  549 + if (mtasFields.doStatsPositions) {
  550 + ArrayList<Object> mtasStatsPositionsResponses = new ArrayList<>();
  551 + for (String field : mtasFields.list.keySet()) {
  552 + for (ComponentPosition position : mtasFields.list
  553 + .get(field).statsPositionList) {
  554 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  555 + false)) {
  556 + mtasStatsPositionsResponses
  557 + .add(searchStats.create(position, true));
  558 + } else {
  559 + mtasStatsPositionsResponses
  560 + .add(searchStats.create(position, false));
  561 + }
  562 + }
  563 + }
  564 + mtasStatsResponse.add(MtasSolrComponentStats.NAME_POSITIONS,
  565 + mtasStatsPositionsResponses);
  566 + }
  567 + if (mtasFields.doStatsSpans) {
  568 + ArrayList<Object> mtasStatsSpansResponses = new ArrayList<>();
  569 + for (String field : mtasFields.list.keySet()) {
  570 + for (ComponentSpan span : mtasFields.list
  571 + .get(field).statsSpanList) {
  572 + if (rb.req.getParams().getBool(ShardParams.IS_SHARD,
  573 + false)) {
  574 + mtasStatsSpansResponses
  575 + .add(searchStats.create(span, true));
  576 + } else {
  577 + mtasStatsSpansResponses
  578 + .add(searchStats.create(span, false));
  579 + }
  580 + }
  581 + }
  582 + mtasStatsResponse.add(MtasSolrComponentStats.NAME_SPANS,
  583 + mtasStatsSpansResponses);
  584 + }
  585 + // add to response
  586 + mtasResponse.add(MtasSolrComponentStats.NAME,
  587 + mtasStatsResponse);
  588 + }
  589 + }
  590 + // add to response
  591 + if(mtasResponse.size()>0) {
  592 + rb.rsp.add(NAME, mtasResponse);
  593 + }
487 594 }
488   - // add to response
489   - mtasResponse.add("stats", mtasStatsResponse);
490 595 }
  596 + } catch (IOException e) {
  597 + errorStatus(solrStatus, e);
491 598 }
492   - // add to response
493   - rb.rsp.add("mtas", mtasResponse);
494 599 }
  600 + if(!solrStatus.error()) {
  601 + //always set status segments
  602 + if(solrStatus.status().numberSegmentsTotal==null) {
  603 + solrStatus.status().numberSegmentsTotal = rb.req.getSearcher().getRawReader().leaves().size();
  604 + solrStatus.status().numberSegmentsFinished = solrStatus.status().numberSegmentsTotal;
  605 + }
  606 + //always try to set number of documents
  607 + if(solrStatus.status().numberDocumentsTotal==null) {
  608 + solrStatus.status().numberDocumentsTotal = (long) rb.req.getSearcher().numDocs();
  609 + if(rb.getResults().docList!=null) {
  610 + solrStatus.status().numberDocumentsFinished = rb.getResults().docList.matches();
  611 + solrStatus.status().numberDocumentsFound = rb.getResults().docList.matches();
  612 + } else if(rb.getResults().docSet!=null) {
  613 + solrStatus.status().numberDocumentsFinished = (long) rb.getResults().docSet.size();
  614 + solrStatus.status().numberDocumentsFound = (long) rb.getResults().docSet.size();
  615 + }
  616 + }
  617 + }
  618 + } finally {
  619 + checkStatus(solrStatus);
  620 + finishStatus(solrStatus);
495 621 }
496 622 }
497 623  
... ... @@ -507,11 +633,28 @@ public class MtasSolrSearchComponent extends SearchComponent {
507 633 @Override
508 634 public void modifyRequest(ResponseBuilder rb, SearchComponent who,
509 635 ShardRequest sreq) {
510   - // System.out.println(System.nanoTime() + " - " +
511   - // Thread.currentThread().getId() + " - "
512   - // + rb.req.getParams().getBool("isShard", false) + " MODIFY REQUEST "
513   - // + rb.stage + " " + rb.req.getParamString());
  636 + // System.out
  637 + // .println(System.nanoTime() + " - " + Thread.currentThread().getId()
  638 + // + " - " + rb.req.getParams().getBool(ShardParams.IS_SHARD, false)
  639 + // + " MODIFY REQUEST " + rb.stage + " " + rb.req.getParamString());
  640 + MtasSolrStatus solrStatus = Objects.requireNonNull(
  641 + (MtasSolrStatus) rb.req.getContext().get(MtasSolrStatus.class),
  642 + "couldn't find status");
  643 + solrStatus.setStage(rb.stage);
514 644 if (sreq.params.getBool(PARAM_MTAS, false)) {
  645 + if (sreq.params.getBool(MtasSolrComponentStatus.PARAM_MTAS_STATUS,
  646 + false)) {
  647 + searchStatus.modifyRequest(rb, who, sreq);
  648 + } else if (requestHandler != null) {
  649 + sreq.params.add(MtasSolrComponentStatus.PARAM_MTAS_STATUS,
  650 + CommonParams.TRUE);
  651 + }
  652 + if (requestHandler != null) {
  653 + sreq.params.add(
  654 + MtasSolrComponentStatus.PARAM_MTAS_STATUS + "."
  655 + + MtasSolrComponentStatus.NAME_MTAS_STATUS_KEY,
  656 + solrStatus.shardKey(rb.stage));
  657 + }
515 658 if (sreq.params.getBool(MtasSolrComponentStats.PARAM_MTAS_STATS, false)) {
516 659 searchStats.modifyRequest(rb, who, sreq);
517 660 }
... ... @@ -557,8 +700,15 @@ public class MtasSolrSearchComponent extends SearchComponent {
557 700 public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
558 701 // System.out
559 702 // .println(System.nanoTime() + " - " + Thread.currentThread().getId()
560   - // + " - " + rb.req.getParams().getBool("isShard", false)
  703 + // + " - " + rb.req.getParams().getBool(ShardParams.IS_SHARD, false)
561 704 // + " HANDLERESPONSES " + rb.stage + " " + rb.req.getParamString());
  705 + MtasSolrStatus solrStatus = Objects.requireNonNull(
  706 + (MtasSolrStatus) rb.req.getContext().get(MtasSolrStatus.class),
  707 + "couldn't find status");
  708 + solrStatus.setStage(rb.stage);
  709 + if (rb.req.getParams().getBool(PARAM_MTAS, false)) {
  710 + // do nothing
  711 + }
562 712 }
563 713  
564 714 /*
... ... @@ -572,8 +722,20 @@ public class MtasSolrSearchComponent extends SearchComponent {
572 722 public void finishStage(ResponseBuilder rb) {
573 723 // System.out
574 724 // .println(System.nanoTime() + " - " + Thread.currentThread().getId()
575   - // + " - " + rb.req.getParams().getBool("isShard", false)
  725 + // + " - " + rb.req.getParams().getBool(ShardParams.IS_SHARD, false)
576 726 // + " FINISHRESPONSES " + rb.stage + " " + rb.req.getParamString());
  727 + MtasSolrStatus solrStatus = Objects.requireNonNull(
  728 + (MtasSolrStatus) rb.req.getContext().get(MtasSolrStatus.class),
  729 + "couldn't find status");
  730 + solrStatus.setStage(rb.stage);
  731 + if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
  732 + Status status = solrStatus.status();
  733 + status.numberDocumentsFound = (status.numberDocumentsFound == null)
  734 + ? rb.getNumberDocumentsFound() : status.numberDocumentsFound;
  735 + // try to finish status from get fields stage
  736 + } else if (rb.stage >= ResponseBuilder.STAGE_GET_FIELDS) {
  737 + finishStatus(solrStatus);
  738 + }
577 739 if (rb.req.getParams().getBool(PARAM_MTAS, false)) {
578 740 if (rb.req.getParams().getBool(MtasSolrComponentStats.PARAM_MTAS_STATS,
579 741 false)) {
... ... @@ -624,11 +786,14 @@ public class MtasSolrSearchComponent extends SearchComponent {
624 786 */
625 787 @Override
626 788 public int distributedProcess(ResponseBuilder rb) throws IOException {
627   - // System.out.println(System.nanoTime() + " - " +
628   - // Thread.currentThread().getId() + " - "
629   - // + rb.req.getParams().getBool("isShard", false) + " DISTIRBUTEDPROCESS "
630   - // + rb.stage + " " + rb.req.getParamString());
631   - // distributed processes
  789 + // System.out.println(System.nanoTime() + " - "
  790 + // + Thread.currentThread().getId() + " - "
  791 + // + rb.req.getParams().getBool(ShardParams.IS_SHARD, false)
  792 + // + " DISTIRBUTEDPROCESS " + rb.stage + " " + rb.req.getParamString());
  793 + MtasSolrStatus solrStatus = Objects.requireNonNull(
  794 + (MtasSolrStatus) rb.req.getContext().get(MtasSolrStatus.class),
  795 + "couldn't find status");
  796 + solrStatus.setStage(rb.stage);
632 797 if (rb.req.getParams().getBool(PARAM_MTAS, false)) {
633 798 if (rb.stage == STAGE_TERMVECTOR_MISSING_TOP
634 799 || rb.stage == STAGE_TERMVECTOR_MISSING_KEY
... ... @@ -711,7 +876,8 @@ public class MtasSolrSearchComponent extends SearchComponent {
711 876 /**
712 877 * Gets the mtas fields.
713 878 *
714   - * @param rb the rb
  879 + * @param rb
  880 + * the rb
715 881 * @return the mtas fields
716 882 */
717 883  
... ... @@ -719,4 +885,96 @@ public class MtasSolrSearchComponent extends SearchComponent {
719 885 return (ComponentFields) rb.req.getContext().get(ComponentFields.class);
720 886 }
721 887  
  888 + /**
  889 + * Initialize request handler.
  890 + *
  891 + * @param rb
  892 + * the rb
  893 + * @throws IOException
  894 + * Signals that an I/O exception has occurred.
  895 + */
  896 + private void initializeRequestHandler(ResponseBuilder rb) {
  897 + if (requestHandler == null) {
  898 + // try to initialize
  899 + for (Entry<String, SolrInfoBean> entry : rb.req.getCore()
  900 + .getInfoRegistry().entrySet()) {
  901 + if (entry.getValue() instanceof MtasRequestHandler) {
  902 + requestHandlerName = entry.getKey();
  903 + requestHandler = (MtasRequestHandler) entry.getValue();
  904 + break;
  905 + }
  906 + }
  907 + }
  908 + }
  909 +
  910 + private void checkStatus(MtasSolrStatus status) throws IOException {
  911 + if (!status.finished()) {
  912 + if (status.error()) {
  913 + status.setFinished();
  914 + if (requestHandler != null) {
  915 + requestHandler.finishStatus(status);
  916 + }
  917 + throw new IOException(status.errorMessage());
  918 + } else if (status.abort()) {
  919 + status.setFinished();
  920 + if (requestHandler != null) {
  921 + requestHandler.finishStatus(status);
  922 + }
  923 + throw new IOException(status.abortMessage());
  924 + }
  925 + }
  926 + }
  927 +
  928 + private void registerStatus(MtasSolrStatus solrStatus) throws IOException {
  929 + if (requestHandler != null) {
  930 + Map<String, ShardStatus> shards = solrStatus.getShards();
  931 + if (shards != null) {
  932 + Status status = solrStatus.status();
  933 + status.numberDocumentsTotal = Long.valueOf(0);
  934 + status.numberSegmentsTotal = 0;
  935 + for (Entry<String, ShardStatus> entry : shards.entrySet()) {
  936 + // get shard info
  937 + ShardInformation shardInformation = requestHandler
  938 + .getShardInformation(entry.getKey());
  939 + if(shardInformation==null) {
  940 + throw new IOException("no shard information "+entry.getKey());
  941 + }
  942 + ShardStatus shardStatus = entry.getValue();
  943 + shardStatus.name = shardInformation.name;
  944 + shardStatus.location = entry.getKey();
  945 + shardStatus.mtasHandler = shardInformation.mtasHandler;
  946 + shardStatus.numberDocumentsTotal = shardInformation.numberOfDocuments;
  947 + shardStatus.numberSegmentsTotal = shardInformation.numberOfSegments;
  948 + status.numberDocumentsTotal += shardInformation.numberOfDocuments;
  949 + status.numberSegmentsTotal += shardInformation.numberOfSegments;
  950 + }
  951 + }
  952 + requestHandler.registerStatus(solrStatus);
  953 + }
  954 + }
  955 +
  956 + private void errorStatus(MtasSolrStatus status, IOException exception) {
  957 + try {
  958 + status.setError(exception);
  959 + if (requestHandler != null) {
  960 + requestHandler.finishStatus(status);
  961 + }
  962 + } catch (IOException e) {
  963 + log.error(e);
  964 + }
  965 + }
  966 +
  967 + private void finishStatus(MtasSolrStatus status) {
  968 + if (!status.finished()) {
  969 + status.setFinished();
  970 + if (requestHandler != null) {
  971 + try {
  972 + requestHandler.finishStatus(status);
  973 + } catch (IOException e) {
  974 + log.error(e);
  975 + }
  976 + }
  977 + }
  978 + }
  979 +
722 980 }
723 981 \ No newline at end of file
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponent.java
... ... @@ -9,6 +9,7 @@ import org.apache.solr.handler.component.ShardRequest;
9 9  
10 10 import mtas.codec.util.CodecComponent.BasicComponent;
11 11 import mtas.codec.util.CodecComponent.ComponentFields;
  12 +import mtas.solr.handler.MtasRequestHandler;
12 13  
13 14 /**
14 15 * The Interface MtasSolrComponent.
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentCollection.java
... ... @@ -12,6 +12,7 @@ import java.util.Map.Entry;
12 12  
13 13 import org.apache.commons.logging.Log;
14 14 import org.apache.commons.logging.LogFactory;
  15 +import org.apache.solr.common.params.CommonParams;
15 16 import org.apache.solr.common.params.ModifiableSolrParams;
16 17 import org.apache.solr.common.util.NamedList;
17 18 import org.apache.solr.common.util.SimpleOrderedMap;
... ... @@ -36,9 +37,12 @@ public class MtasSolrComponentCollection
36 37 private static final Log log = LogFactory
37 38 .getLog(MtasSolrComponentCollection.class);
38 39  
  40 + /** The Constant NAME. */
  41 + public static final String NAME = "collection";
  42 +
39 43 /** The Constant PARAM_MTAS_COLLECTION. */
40 44 public static final String PARAM_MTAS_COLLECTION = MtasSolrSearchComponent.PARAM_MTAS
41   - + ".collection";
  45 + + "." + NAME;
42 46  
43 47 /** The Constant NAME_MTAS_COLLECTION_ACTION. */
44 48 public static final String NAME_MTAS_COLLECTION_ACTION = "action";
... ... @@ -67,8 +71,7 @@ public class MtasSolrComponentCollection
67 71 /**
68 72 * Instantiates a new mtas solr component collection.
69 73 *
70   - * @param searchComponent
71   - * the search component
  74 + * @param searchComponent the search component
72 75 */
73 76 public MtasSolrComponentCollection(MtasSolrSearchComponent searchComponent) {
74 77 this.searchComponent = searchComponent;
... ... @@ -328,13 +331,10 @@ public class MtasSolrComponentCollection
328 331 /**
329 332 * Creates the mtas solr collection result.
330 333 *
331   - * @param componentCollection
332   - * the component collection
333   - * @param storeIfRelevant
334   - * the store if relevant
  334 + * @param componentCollection the component collection
  335 + * @param storeIfRelevant the store if relevant
335 336 * @return the mtas solr collection result
336   - * @throws IOException
337   - * Signals that an I/O exception has occurred.
  337 + * @throws IOException Signals that an I/O exception has occurred.
338 338 */
339 339 /*
340 340 * (non-Javadoc)
... ... @@ -443,23 +443,23 @@ public class MtasSolrComponentCollection
443 443 // mtas response
444 444 NamedList<Object> mtasResponse = null;
445 445 try {
446   - mtasResponse = (NamedList<Object>) rb.rsp.getValues().get("mtas");
  446 + mtasResponse = (NamedList<Object>) rb.rsp.getValues().get(MtasSolrSearchComponent.NAME);
447 447 } catch (ClassCastException e) {
448 448 log.debug(e);
449 449 mtasResponse = null;
450 450 }
451 451 if (mtasResponse == null) {
452 452 mtasResponse = new SimpleOrderedMap<>();
453   - rb.rsp.add("mtas", mtasResponse);
  453 + rb.rsp.add(MtasSolrSearchComponent.NAME, mtasResponse);
454 454 }
455 455 ArrayList<Object> mtasCollectionResponses;
456   - if (mtasResponse.get("collection") != null
457   - && mtasResponse.get("collection") instanceof ArrayList) {
  456 + if (mtasResponse.get(NAME) != null
  457 + && mtasResponse.get(NAME) instanceof ArrayList) {
458 458 mtasCollectionResponses = (ArrayList<Object>) mtasResponse
459   - .get("collection");
  459 + .get(NAME);
460 460 } else {
461 461 mtasCollectionResponses = new ArrayList<>();
462   - mtasResponse.add("collection", mtasCollectionResponses);
  462 + mtasResponse.add(NAME, mtasCollectionResponses);
463 463 }
464 464 MtasSolrCollectionResult collectionResult;
465 465 for (ComponentCollection componentCollection : mtasFields.collection) {
... ... @@ -485,7 +485,7 @@ public class MtasSolrComponentCollection
485 485 .getSolrResponse().getResponse();
486 486 try {
487 487 ArrayList<SimpleOrderedMap<Object>> data = (ArrayList<SimpleOrderedMap<Object>>) solrShardResponse
488   - .findRecursive("mtas", "collection");
  488 + .findRecursive(MtasSolrSearchComponent.NAME, NAME);
489 489 if (data != null) {
490 490 MtasSolrResultUtil.decode(data);
491 491 if (rb.stage > ResponseBuilder.STAGE_EXECUTE_QUERY) {
... ... @@ -551,7 +551,7 @@ public class MtasSolrComponentCollection
551 551 // + rb.stage + " " + rb.req.getParamString());
552 552 NamedList<Object> mtasResponse = null;
553 553 try {
554   - mtasResponse = (NamedList<Object>) rb.rsp.getValues().get("mtas");
  554 + mtasResponse = (NamedList<Object>) rb.rsp.getValues().get(MtasSolrSearchComponent.NAME);
555 555 } catch (ClassCastException e) {
556 556 log.debug(e);
557 557 mtasResponse = null;
... ... @@ -563,7 +563,7 @@ public class MtasSolrComponentCollection
563 563 ArrayList<Object> mtasResponseCollection;
564 564 try {
565 565 mtasResponseCollection = (ArrayList<Object>) mtasResponse
566   - .get("collection");
  566 + .get(NAME);
567 567 for (Object item : mtasResponseCollection) {
568 568 if (item instanceof SimpleOrderedMap) {
569 569 SimpleOrderedMap<Object> itemMap = (SimpleOrderedMap<Object>) item;
... ... @@ -577,7 +577,7 @@ public class MtasSolrComponentCollection
577 577 }
578 578 } catch (ClassCastException e) {
579 579 log.debug(e);
580   - mtasResponse.remove("collection");
  580 + mtasResponse.remove(NAME);
581 581 }
582 582 // check and remove previous responses
583 583 Map<String, Set<String>> createPostAfterMissingCheckResult = new HashMap<>();
... ... @@ -589,7 +589,7 @@ public class MtasSolrComponentCollection
589 589 .getSolrResponse().getResponse();
590 590 try {
591 591 ArrayList<SimpleOrderedMap<Object>> data = (ArrayList<SimpleOrderedMap<Object>>) solrShardResponse
592   - .findRecursive("mtas", "collection");
  592 + .findRecursive(MtasSolrSearchComponent.NAME, NAME);
593 593 if (data != null) {
594 594 for (SimpleOrderedMap<Object> dataItem : data) {
595 595 if (dataItem.get("data") != null && dataItem
... ... @@ -704,8 +704,8 @@ public class MtasSolrComponentCollection
704 704 newSreq.shards = new String[] { entry.getKey() };
705 705 newSreq.purpose = ShardRequest.PURPOSE_PRIVATE;
706 706 newSreq.params = entry.getValue();
707   - newSreq.params.add("q", "*");
708   - newSreq.params.add("rows", "0");
  707 + newSreq.params.add(CommonParams.Q, "*");
  708 + newSreq.params.add(CommonParams.ROWS, "0");
709 709 newSreq.params.add(MtasSolrSearchComponent.PARAM_MTAS,
710 710 rb.req.getOriginalParams()
711 711 .getParams(MtasSolrSearchComponent.PARAM_MTAS));
... ... @@ -718,13 +718,13 @@ public class MtasSolrComponentCollection
718 718 ArrayList<Object> mtasResponseCollection;
719 719 try {
720 720 mtasResponseCollection = (ArrayList<Object>) mtasResponse
721   - .get("collection");
  721 + .get(NAME);
722 722 if (mtasResponseCollection != null) {
723 723 MtasSolrResultUtil.rewrite(mtasResponseCollection, searchComponent);
724 724 }
725 725 } catch (ClassCastException e) {
726 726 log.debug(e);
727   - mtasResponse.remove("collection");
  727 + mtasResponse.remove(NAME);
728 728 }
729 729 }
730 730 }
... ... @@ -733,8 +733,7 @@ public class MtasSolrComponentCollection
733 733 /**
734 734 * Gets the mtas fields.
735 735 *
736   - * @param rb
737   - * the rb
  736 + * @param rb the rb
738 737 * @return the mtas fields
739 738 */
740 739 private ComponentFields getMtasFields(ResponseBuilder rb) {
... ... @@ -744,8 +743,7 @@ public class MtasSolrComponentCollection
744 743 /**
745 744 * String values to string.
746 745 *
747   - * @param stringValues
748   - * the string values
  746 + * @param stringValues the string values
749 747 * @return the string
750 748 */
751 749 private static String stringValuesToString(HashSet<String> stringValues) {
... ... @@ -755,11 +753,9 @@ public class MtasSolrComponentCollection
755 753 /**
756 754 * String to string values.
757 755 *
758   - * @param stringValue
759   - * the string value
  756 + * @param stringValue the string value
760 757 * @return the hash set
761   - * @throws IOException
762   - * Signals that an I/O exception has occurred.
  758 + * @throws IOException Signals that an I/O exception has occurred.
763 759 */
764 760 private static HashSet<String> stringToStringValues(String stringValue)
765 761 throws IOException {
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentDocument.java
... ... @@ -23,6 +23,7 @@ import mtas.solr.handler.component.MtasSolrSearchComponent;
23 23 /**
24 24 * The Class MtasSolrComponentDocument.
25 25 */
  26 +
26 27 public class MtasSolrComponentDocument
27 28 implements MtasSolrComponent<ComponentDocument> {
28 29  
... ... @@ -30,9 +31,12 @@ public class MtasSolrComponentDocument
30 31 private static final Log log = LogFactory
31 32 .getLog(MtasSolrComponentDocument.class);
32 33  
  34 + /** The Constant NAME. */
  35 + public static final String NAME = "document";
  36 +
33 37 /** The Constant PARAM_MTAS_DOCUMENT. */
34 38 public static final String PARAM_MTAS_DOCUMENT = MtasSolrSearchComponent.PARAM_MTAS
35   - + ".document";
  39 + + "." + NAME;
36 40  
37 41 /** The Constant NAME_MTAS_DOCUMENT_FIELD. */
38 42 public static final String NAME_MTAS_DOCUMENT_FIELD = "field";
... ... @@ -246,13 +250,15 @@ public class MtasSolrComponentDocument
246 250 document.uniqueKey.get(docId));
247 251 if (list != null) {
248 252 if (document.listExpand) {
249   - mtasDocumentItemResponse.add("list", new MtasSolrMtasResult(list,
250   - new String[] { list.getDataType(), list.getDataType() },
251   - new String[] { list.getStatsType(), list.getStatsType() },
252   - new SortedSet[] { list.getStatsItems(), list.getStatsItems() },
253   - new List[] {null, null},
254   - new String[] { null, null }, new String[] { null, null },
255   - new Integer[] { 0, 0 }, new Integer[] { 1, 1 }, null));
  253 + mtasDocumentItemResponse.add("list",
  254 + new MtasSolrMtasResult(list,
  255 + new String[] { list.getDataType(), list.getDataType() },
  256 + new String[] { list.getStatsType(), list.getStatsType() },
  257 + new SortedSet[] { list.getStatsItems(),
  258 + list.getStatsItems() },
  259 + new List[] { null, null }, new String[] { null, null },
  260 + new String[] { null, null }, new Integer[] { 0, 0 },
  261 + new Integer[] { 1, 1 }, null));
256 262 } else {
257 263 mtasDocumentItemResponse.add("list",
258 264 new MtasSolrMtasResult(list, list.getDataType(),
... ... @@ -342,7 +348,7 @@ public class MtasSolrComponentDocument
342 348 if (mtasResponse != null) {
343 349 ArrayList<Object> mtasResponseDocument;
344 350 try {
345   - mtasResponseDocument = (ArrayList<Object>) mtasResponse.get("document");
  351 + mtasResponseDocument = (ArrayList<Object>) mtasResponse.get(NAME);
346 352 if (mtasResponseDocument != null) {
347 353 MtasSolrResultUtil.rewrite(mtasResponseDocument, searchComponent);
348 354 }
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentFacet.java
... ... @@ -32,7 +32,6 @@ import mtas.solr.handler.component.MtasSolrSearchComponent;
32 32 /**
33 33 * The Class MtasSolrComponentFacet.
34 34 */
35   -@SuppressWarnings("deprecation")
36 35 public class MtasSolrComponentFacet
37 36 implements MtasSolrComponent<ComponentFacet> {
38 37  
... ... @@ -43,9 +42,12 @@ public class MtasSolrComponentFacet
43 42 /** The search component. */
44 43 MtasSolrSearchComponent searchComponent;
45 44  
  45 + /** The Constant NAME. */
  46 + public static final String NAME = "facet";
  47 +
46 48 /** The Constant PARAM_MTAS_FACET. */
47 49 public static final String PARAM_MTAS_FACET = MtasSolrSearchComponent.PARAM_MTAS
48   - + ".facet";
  50 + + "." + NAME;
49 51  
50 52 /** The Constant NAME_MTAS_FACET_KEY. */
51 53 public static final String NAME_MTAS_FACET_KEY = "key";
... ... @@ -128,8 +130,7 @@ public class MtasSolrComponentFacet
128 130 /**
129 131 * Instantiates a new mtas solr component facet.
130 132 *
131   - * @param searchComponent
132   - * the search component
  133 + * @param searchComponent the search component
133 134 */
134 135 public MtasSolrComponentFacet(MtasSolrSearchComponent searchComponent) {
135 136 this.searchComponent = searchComponent;
... ... @@ -567,7 +568,7 @@ public class MtasSolrComponentFacet
567 568 }
568 569 }
569 570 MtasSolrMtasResult data = new MtasSolrMtasResult(facet.dataCollector,
570   - facet.baseDataTypes, facet.baseStatsTypes, facet.baseStatsItems,null,
  571 + facet.baseDataTypes, facet.baseStatsTypes, facet.baseStatsItems, null,
571 572 facet.baseSortTypes, facet.baseSortDirections, null, facet.baseNumbers,
572 573 functionData);
573 574  
... ... @@ -600,7 +601,7 @@ public class MtasSolrComponentFacet
600 601 .getResponse();
601 602 try {
602 603 ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response
603   - .findRecursive("mtas", "facet");
  604 + .findRecursive("mtas", NAME);
604 605 if (data != null) {
605 606 MtasSolrResultUtil.decode(data);
606 607 }
... ... @@ -636,13 +637,13 @@ public class MtasSolrComponentFacet
636 637 if (mtasResponse != null) {
637 638 ArrayList<Object> mtasResponseFacet;
638 639 try {
639   - mtasResponseFacet = (ArrayList<Object>) mtasResponse.get("facet");
  640 + mtasResponseFacet = (ArrayList<Object>) mtasResponse.get(NAME);
640 641 if (mtasResponseFacet != null) {
641 642 MtasSolrResultUtil.rewrite(mtasResponseFacet, searchComponent);
642 643 }
643 644 } catch (ClassCastException e) {
644 645 log.debug(e);
645   - mtasResponse.remove("facet");
  646 + mtasResponse.remove(NAME);
646 647 }
647 648 }
648 649 }
... ... @@ -650,28 +651,27 @@ public class MtasSolrComponentFacet
650 651 /**
651 652 * Gets the field type.
652 653 *
653   - * @param schema
654   - * the schema
655   - * @param field
656   - * the field
  654 + * @param schema the schema
  655 + * @param field the field
657 656 * @return the field type
658   - * @throws IOException
  657 + * @throws IOException Signals that an I/O exception has occurred.
659 658 */
660   - private String getFieldType(IndexSchema schema, String field) throws IOException {
  659 + private String getFieldType(IndexSchema schema, String field)
  660 + throws IOException {
661 661 SchemaField sf = schema.getField(field);
662 662 FieldType ft = sf.getType();
663 663 if (ft != null) {
664   - if(ft.isPointField() && !sf.hasDocValues()) {
  664 + if (ft.isPointField() && !sf.hasDocValues()) {
665 665 return ComponentFacet.TYPE_POINTFIELD_WITHOUT_DOCVALUES;
666 666 }
667   - NumberType nt = ft.getNumberType();
668   - if(nt!=null) {
  667 + NumberType nt = ft.getNumberType();
  668 + if (nt != null) {
669 669 return nt.name();
670 670 } else {
671 671 return ComponentFacet.TYPE_STRING;
672 672 }
673 673 } else {
674   - //best guess
  674 + // best guess
675 675 return ComponentFacet.TYPE_STRING;
676 676 }
677 677 }
... ... @@ -679,8 +679,7 @@ public class MtasSolrComponentFacet
679 679 /**
680 680 * Gets the positive integer.
681 681 *
682   - * @param number
683   - * the number
  682 + * @param number the number
684 683 * @return the positive integer
685 684 */
686 685 private int getPositiveInteger(String number) {
... ... @@ -694,8 +693,7 @@ public class MtasSolrComponentFacet
694 693 /**
695 694 * Gets the double.
696 695 *
697   - * @param number
698   - * the number
  696 + * @param number the number
699 697 * @return the double
700 698 */
701 699 private Double getDouble(String number) {
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentGroup.java
... ... @@ -36,9 +36,12 @@ public class MtasSolrComponentGroup
36 36 /** The search component. */
37 37 MtasSolrSearchComponent searchComponent;
38 38  
  39 + /** The Constant NAME. */
  40 + public static final String NAME = "group";
  41 +
39 42 /** The Constant PARAM_MTAS_GROUP. */
40 43 public static final String PARAM_MTAS_GROUP = MtasSolrSearchComponent.PARAM_MTAS
41   - + ".group";
  44 + + "." + NAME;
42 45  
43 46 /** The Constant NAME_MTAS_GROUP_FIELD. */
44 47 public static final String NAME_MTAS_GROUP_FIELD = "field";
... ... @@ -109,8 +112,7 @@ public class MtasSolrComponentGroup
109 112 /**
110 113 * Instantiates a new mtas solr component group.
111 114 *
112   - * @param searchComponent
113   - * the search component
  115 + * @param searchComponent the search component
114 116 */
115 117 public MtasSolrComponentGroup(MtasSolrSearchComponent searchComponent) {
116 118 this.searchComponent = searchComponent;
... ... @@ -335,21 +337,41 @@ public class MtasSolrComponentGroup
335 337 }
336 338 }
337 339  
  340 + /*
  341 + * (non-Javadoc)
  342 + *
  343 + * @see
  344 + * mtas.solr.handler.component.util.MtasSolrComponent#create(mtas.codec.util.
  345 + * CodecComponent.BasicComponent, java.lang.Boolean)
  346 + */
  347 + @SuppressWarnings("unchecked")
  348 + public SimpleOrderedMap<Object> create(ComponentGroup group, Boolean encode)
  349 + throws IOException {
  350 + SimpleOrderedMap<Object> mtasGroupResponse = new SimpleOrderedMap<>();
  351 + mtasGroupResponse.add("key", group.key);
  352 + MtasSolrMtasResult data = new MtasSolrMtasResult(group.dataCollector,
  353 + new String[] { group.dataType }, new String[] { group.statsType },
  354 + new SortedSet[] { group.statsItems }, new List[] { null },
  355 + new String[] { group.sortType }, new String[] { group.sortDirection },
  356 + new Integer[] { group.start }, new Integer[] { group.number }, null);
  357 + if (encode) {
  358 + mtasGroupResponse.add("_encoded_list", MtasSolrResultUtil.encode(data));
  359 + } else {
  360 + mtasGroupResponse.add("list", data);
  361 + MtasSolrResultUtil.rewrite(mtasGroupResponse, searchComponent);
  362 + }
  363 + return mtasGroupResponse;
  364 + }
  365 +
338 366 /**
339 367 * Prepare.
340 368 *
341   - * @param solrParams
342   - * the solr params
343   - * @param gids
344   - * the gids
345   - * @param name
346   - * the name
347   - * @param positions
348   - * the positions
349   - * @param prefixes
350   - * the prefixes
351   - * @throws IOException
352   - * Signals that an I/O exception has occurred.
  369 + * @param solrParams the solr params
  370 + * @param gids the gids
  371 + * @param name the name
  372 + * @param positions the positions
  373 + * @param prefixes the prefixes
  374 + * @throws IOException Signals that an I/O exception has occurred.
353 375 */
354 376 private void prepare(SolrParams solrParams, SortedSet<String> gids,
355 377 String name, String[] positions, String[] prefixes) throws IOException {
... ... @@ -384,15 +406,15 @@ public class MtasSolrComponentGroup
384 406 if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
385 407 && sreq.params.getBool(PARAM_MTAS_GROUP, false)) {
386 408 if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
387   - //do nothing
388   -// Set<String> keys = MtasSolrResultUtil
389   -// .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_GROUP);
390   -// for (String key : keys) {
391   -// sreq.params.remove(
392   -// PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_NUMBER);
393   -// sreq.params.remove(
394   -// PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_START);
395   -// }
  409 + // do nothing
  410 + // Set<String> keys = MtasSolrResultUtil
  411 + // .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_GROUP);
  412 + // for (String key : keys) {
  413 + // sreq.params.remove(
  414 + // PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_NUMBER);
  415 + // sreq.params.remove(
  416 + // PARAM_MTAS_GROUP + "." + key + "." + NAME_MTAS_GROUP_START);
  417 + // }
396 418 } else {
397 419 // remove prefix for other requests
398 420 Set<String> keys = MtasSolrResultUtil
... ... @@ -482,41 +504,15 @@ public class MtasSolrComponentGroup
482 504 * (non-Javadoc)
483 505 *
484 506 * @see
485   - * mtas.solr.handler.component.util.MtasSolrComponent#create(mtas.codec.util.
486   - * CodecComponent.BasicComponent, java.lang.Boolean)
487   - */
488   - @SuppressWarnings("unchecked")
489   - public SimpleOrderedMap<Object> create(ComponentGroup group, Boolean encode)
490   - throws IOException {
491   - SimpleOrderedMap<Object> mtasGroupResponse = new SimpleOrderedMap<>();
492   - mtasGroupResponse.add("key", group.key);
493   - MtasSolrMtasResult data = new MtasSolrMtasResult(group.dataCollector,
494   - new String[] { group.dataType }, new String[] { group.statsType },
495   - new SortedSet[] { group.statsItems }, new List[] {null}, new String[] { group.sortType },
496   - new String[] { group.sortDirection }, new Integer[] { group.start },
497   - new Integer[] { group.number }, null);
498   - if (encode) {
499   - mtasGroupResponse.add("_encoded_list", MtasSolrResultUtil.encode(data));
500   - } else {
501   - mtasGroupResponse.add("list", data);
502   - MtasSolrResultUtil.rewrite(mtasGroupResponse, searchComponent);
503   - }
504   - return mtasGroupResponse;
505   - }
506   -
507   - /*
508   - * (non-Javadoc)
509   - *
510   - * @see
511 507 * mtas.solr.handler.component.util.MtasSolrComponent#finishStage(org.apache.
512 508 * solr.handler.component.ResponseBuilder)
513 509 */
514 510 @SuppressWarnings("unchecked")
515   - public void finishStage(ResponseBuilder rb) {
  511 + public void finishStage(ResponseBuilder rb) {
516 512 if (rb.req.getParams().getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
517 513 && rb.stage >= ResponseBuilder.STAGE_EXECUTE_QUERY
518 514 && rb.stage < ResponseBuilder.STAGE_GET_FIELDS) {
519   - //decode finished results
  515 + // decode finished results
520 516 for (ShardRequest sreq : rb.finished) {
521 517 if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
522 518 && sreq.params.getBool(PARAM_MTAS_GROUP, false)) {
... ... @@ -525,7 +521,7 @@ public class MtasSolrComponentGroup
525 521 .getResponse();
526 522 try {
527 523 ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response
528   - .findRecursive("mtas", "group");
  524 + .findRecursive("mtas", NAME);
529 525 if (data != null) {
530 526 MtasSolrResultUtil.decode(data);
531 527 }
... ... @@ -561,13 +557,13 @@ public class MtasSolrComponentGroup
561 557 if (mtasResponse != null) {
562 558 ArrayList<Object> mtasResponseGroup;
563 559 try {
564   - mtasResponseGroup = (ArrayList<Object>) mtasResponse.get("group");
  560 + mtasResponseGroup = (ArrayList<Object>) mtasResponse.get(NAME);
565 561 if (mtasResponseGroup != null) {
566 562 MtasSolrResultUtil.rewrite(mtasResponseGroup, searchComponent);
567 563 }
568 564 } catch (ClassCastException e) {
569 565 log.debug(e);
570   - mtasResponse.remove("group");
  566 + mtasResponse.remove(NAME);
571 567 }
572 568 }
573 569 }
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentKwic.java
... ... @@ -31,9 +31,12 @@ import mtas.solr.handler.component.MtasSolrSearchComponent;
31 31 */
32 32 public class MtasSolrComponentKwic implements MtasSolrComponent<ComponentKwic> {
33 33  
  34 + /** The Constant NAME. */
  35 + public static final String NAME = "kwic";
  36 +
34 37 /** The Constant PARAM_MTAS_KWIC. */
35 38 public static final String PARAM_MTAS_KWIC = MtasSolrSearchComponent.PARAM_MTAS
36   - + ".kwic";
  39 + + "." + NAME;
37 40  
38 41 /** The Constant NAME_MTAS_KWIC_FIELD. */
39 42 public static final String NAME_MTAS_KWIC_FIELD = "field";
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentList.java
... ... @@ -12,6 +12,7 @@ import java.util.TreeMap;
12 12  
13 13 import org.apache.commons.logging.Log;
14 14 import org.apache.commons.logging.LogFactory;
  15 +import org.apache.solr.common.params.CommonParams;
15 16 import org.apache.solr.common.params.ModifiableSolrParams;
16 17 import org.apache.solr.common.util.NamedList;
17 18 import org.apache.solr.common.util.SimpleOrderedMap;
... ... @@ -38,12 +39,15 @@ public class MtasSolrComponentList implements MtasSolrComponent&lt;ComponentList&gt; {
38 39 /** The Constant log. */
39 40 private static final Log log = LogFactory.getLog(MtasSolrComponentList.class);
40 41  
  42 + /** The Constant NAME. */
  43 + public static final String NAME = "list";
  44 +
41 45 /** The search component. */
42 46 MtasSolrSearchComponent searchComponent;
43 47  
44 48 /** The Constant PARAM_MTAS_LIST. */
45 49 public static final String PARAM_MTAS_LIST = MtasSolrSearchComponent.PARAM_MTAS
46   - + ".list";
  50 + + "." + NAME;
47 51  
48 52 /** The Constant NAME_MTAS_LIST_FIELD. */
49 53 public static final String NAME_MTAS_LIST_FIELD = "field";
... ... @@ -372,7 +376,7 @@ public class MtasSolrComponentList implements MtasSolrComponent&lt;ComponentList&gt; {
372 376 NamedList<Object> result = response.getSolrResponse().getResponse();
373 377 try {
374 378 ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) result
375   - .findRecursive("mtas", "list");
  379 + .findRecursive("mtas", NAME);
376 380 if (data != null) {
377 381 for (NamedList<Object> dataItem : data) {
378 382 Object key = dataItem.get("key");
... ... @@ -487,10 +491,10 @@ public class MtasSolrComponentList implements MtasSolrComponent&lt;ComponentList&gt; {
487 491 sreq.shards = new String[] { entry.getKey() };
488 492 sreq.purpose = ShardRequest.PURPOSE_PRIVATE;
489 493 sreq.params = new ModifiableSolrParams();
490   - sreq.params.add("fq", rb.req.getParams().getParams("fq"));
491   - sreq.params.add("q", rb.req.getParams().getParams("q"));
492   - sreq.params.add("cache", rb.req.getParams().getParams("cache"));
493   - sreq.params.add("rows", "0");
  494 + sreq.params.add(CommonParams.FQ, rb.req.getParams().getParams(CommonParams.FQ));
  495 + sreq.params.add(CommonParams.Q, rb.req.getParams().getParams(CommonParams.Q));
  496 + sreq.params.add(CommonParams.CACHE, rb.req.getParams().getParams(CommonParams.CACHE));
  497 + sreq.params.add(CommonParams.ROWS, "0");
494 498 sreq.params.add(MtasSolrSearchComponent.PARAM_MTAS, rb.req
495 499 .getOriginalParams().getParams(MtasSolrSearchComponent.PARAM_MTAS));
496 500 sreq.params.add(PARAM_MTAS_LIST,
... ... @@ -633,7 +637,7 @@ public class MtasSolrComponentList implements MtasSolrComponent&lt;ComponentList&gt; {
633 637 mtasListItemResponses.add(mtasListItemResponse);
634 638 }
635 639 }
636   - mtasListResponse.add("list", mtasListItemResponses);
  640 + mtasListResponse.add(NAME, mtasListItemResponses);
637 641 }
638 642 return mtasListResponse;
639 643 }
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentPrefix.java
... ... @@ -32,6 +32,9 @@ public class MtasSolrComponentPrefix
32 32 /** The search component. */
33 33 MtasSolrSearchComponent searchComponent;
34 34  
  35 + /** The Constant NAME. */
  36 + public static final String NAME = "prefix";
  37 +
35 38 /** The Constant PARAM_MTAS_PREFIX. */
36 39 public static final String PARAM_MTAS_PREFIX = MtasSolrSearchComponent.PARAM_MTAS
37 40 + ".prefix";
... ... @@ -177,7 +180,7 @@ public class MtasSolrComponentPrefix
177 180 .getResponse();
178 181 try {
179 182 ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response
180   - .findRecursive("mtas", "prefix");
  183 + .findRecursive("mtas", NAME);
181 184 if (data != null) {
182 185 MtasSolrResultUtil.decode(data);
183 186 }
... ... @@ -213,7 +216,7 @@ public class MtasSolrComponentPrefix
213 216 if (mtasResponse != null) {
214 217 ArrayList<Object> mtasResponsePrefix;
215 218 try {
216   - mtasResponsePrefix = (ArrayList<Object>) mtasResponse.get("prefix");
  219 + mtasResponsePrefix = (ArrayList<Object>) mtasResponse.get(NAME);
217 220 if (mtasResponsePrefix != null) {
218 221 NamedList<Object> mtasResponsePrefixItem;
219 222 for (Object mtasResponsePrefixItemRaw : mtasResponsePrefix) {
... ... @@ -224,7 +227,7 @@ public class MtasSolrComponentPrefix
224 227 }
225 228 } catch (ClassCastException e) {
226 229 log.debug(e);
227   - mtasResponse.remove("prefix");
  230 + mtasResponse.remove(NAME);
228 231 }
229 232 }
230 233 }
... ... @@ -239,7 +242,7 @@ public class MtasSolrComponentPrefix
239 242 // repair prefix lists
240 243 try {
241 244 ArrayList<NamedList<?>> list = (ArrayList<NamedList<?>>) mtasResponse
242   - .findRecursive("prefix");
  245 + .findRecursive(NAME);
243 246 // MtasSolrResultUtil.rewrite(list);
244 247 if (list != null) {
245 248 for (NamedList<?> item : list) {
... ...
src/main/java/mtas/solr/handler/component/util/MtasSolrComponentStats.java
... ... @@ -44,13 +44,20 @@ public class MtasSolrComponentStats
44 44 /** The search component. */
45 45 MtasSolrSearchComponent searchComponent;
46 46  
  47 + /** The Constant NAME. */
  48 + public static final String NAME = "stats";
  49 +
  50 + public static final String NAME_POSITIONS = "positions";
  51 + public static final String NAME_TOKENS = "tokens";
  52 + public static final String NAME_SPANS = "spans";
  53 +
47 54 /** The Constant PARAM_MTAS_STATS. */
48 55 public static final String PARAM_MTAS_STATS = MtasSolrSearchComponent.PARAM_MTAS
49   - + ".stats";
  56 + + "." + NAME;
50 57  
51 58 /** The Constant PARAM_MTAS_STATS_POSITIONS. */
52 59 public static final String PARAM_MTAS_STATS_POSITIONS = PARAM_MTAS_STATS
53   - + ".positions";
  60 + + "." + NAME_POSITIONS;
54 61  
55 62 /** The Constant NAME_MTAS_STATS_POSITIONS_FIELD. */
56 63 public static final String NAME_MTAS_STATS_POSITIONS_FIELD = "field";
... ... @@ -69,7 +76,7 @@ public class MtasSolrComponentStats
69 76  
70 77 /** The Constant PARAM_MTAS_STATS_TOKENS. */
71 78 public static final String PARAM_MTAS_STATS_TOKENS = PARAM_MTAS_STATS
72   - + ".tokens";
  79 + + "." + NAME_TOKENS;
73 80  
74 81 /** The Constant NAME_MTAS_STATS_TOKENS_FIELD. */
75 82 public static final String NAME_MTAS_STATS_TOKENS_FIELD = "field";
... ... @@ -88,7 +95,7 @@ public class MtasSolrComponentStats
88 95  
89 96 /** The Constant PARAM_MTAS_STATS_SPANS. */
90 97 public static final String PARAM_MTAS_STATS_SPANS = PARAM_MTAS_STATS
91   - + ".spans";
  98 + + "." + NAME_SPANS;
92 99  
93 100 /** The Constant NAME_MTAS_STATS_SPANS_FIELD. */
94 101 public static final String NAME_MTAS_STATS_SPANS_FIELD = "field";
... ... @@ -969,7 +976,7 @@ public class MtasSolrComponentStats
969 976 .getResponse();
970 977 try {
971 978 ArrayList<NamedList<Object>> data = (ArrayList<NamedList<Object>>) response
972   - .findRecursive("mtas", "stats");
  979 + .findRecursive("mtas", NAME);
973 980 if (data != null) {
974 981 MtasSolrResultUtil.decode(data);
975 982 }
... ... @@ -1005,13 +1012,13 @@ public class MtasSolrComponentStats
1005 1012 if (mtasResponse != null) {
1006 1013 NamedList<Object> mtasResponseStats;
1007 1014 try {
1008   - mtasResponseStats = (NamedList<Object>) mtasResponse.get("stats");
  1015 + mtasResponseStats = (NamedList<Object>) mtasResponse.get(NAME);
1009 1016 if (mtasResponseStats != null) {
1010 1017 MtasSolrResultUtil.rewrite(mtasResponseStats, searchComponent);
1011 1018 }
1012 1019 } catch (ClassCastException e) {
1013 1020 log.debug(e);
1014   - mtasResponse.remove("stats");
  1021 + mtasResponse.remove(NAME);
1015 1022 }
1016 1023 }
1017 1024 }
... ...