@Test public void rewriteMincountFacetPivotOption_mincountMissing_shouldSetPivotMinCountToOne() { ModifiableSolrParams fixed = new ModifiableSolrParams(); when(mockParams.getParameterNamesIterator()).thenReturn(Iterators.empty()); when(mockParams.get(ShardParams.SHARDS_PURPOSE)).thenReturn(null); Map<String, String> fieldMappings = new HashMap<>(); rewriteFacetParametersComponent.rewriteMincountFacetFieldOption(fixed, mockParams, "facet.pivot.mincount", fieldMappings, mockRequest); String actual = fixed.get("facet.pivot.mincount"); assertEquals("Expected the existing mincount to be preserved.", "1", actual); }
protected void rewriteMincountFacetFieldOption(ModifiableSolrParams fixed, SolrParams params, String paramName, Map<String, String> fieldMappings, SolrQueryRequest req) { rewriteFacetFieldOptions(fixed, params, paramName, fieldMappings); String shardPurpose = req.getParams().get(ShardParams.SHARDS_PURPOSE); boolean isInitialDistributedRequest = (shardPurpose==null); if(isInitialDistributedRequest) { Map<String, Integer> updatedValues = new HashMap<>(); for (Iterator<String> renamedParameters = fixed.getParameterNamesIterator(); renamedParameters.hasNext(); ) { String solrParameter = renamedParameters.next(); if (solrParameter.endsWith("." + paramName)) { int value = Integer.valueOf(fixed.get(solrParameter)); updatedValues.put(solrParameter, Math.max(value, 1)); } } for (Map.Entry<String, Integer> updatedParameterValues : updatedValues.entrySet()) { fixed.set(updatedParameterValues.getKey(), updatedParameterValues.getValue()); } String paramValue = params.get(paramName); int value = 0; if (paramValue != null) { value = Integer.valueOf(paramValue); } fixed.set(paramName, Math.max(value, 1)); } }
RewriteFacetParametersComponent extends SearchComponent { protected void rewriteMincountFacetFieldOption(ModifiableSolrParams fixed, SolrParams params, String paramName, Map<String, String> fieldMappings, SolrQueryRequest req) { rewriteFacetFieldOptions(fixed, params, paramName, fieldMappings); String shardPurpose = req.getParams().get(ShardParams.SHARDS_PURPOSE); boolean isInitialDistributedRequest = (shardPurpose==null); if(isInitialDistributedRequest) { Map<String, Integer> updatedValues = new HashMap<>(); for (Iterator<String> renamedParameters = fixed.getParameterNamesIterator(); renamedParameters.hasNext(); ) { String solrParameter = renamedParameters.next(); if (solrParameter.endsWith("." + paramName)) { int value = Integer.valueOf(fixed.get(solrParameter)); updatedValues.put(solrParameter, Math.max(value, 1)); } } for (Map.Entry<String, Integer> updatedParameterValues : updatedValues.entrySet()) { fixed.set(updatedParameterValues.getKey(), updatedParameterValues.getValue()); } String paramValue = params.get(paramName); int value = 0; if (paramValue != null) { value = Integer.valueOf(paramValue); } fixed.set(paramName, Math.max(value, 1)); } } }
RewriteFacetParametersComponent extends SearchComponent { protected void rewriteMincountFacetFieldOption(ModifiableSolrParams fixed, SolrParams params, String paramName, Map<String, String> fieldMappings, SolrQueryRequest req) { rewriteFacetFieldOptions(fixed, params, paramName, fieldMappings); String shardPurpose = req.getParams().get(ShardParams.SHARDS_PURPOSE); boolean isInitialDistributedRequest = (shardPurpose==null); if(isInitialDistributedRequest) { Map<String, Integer> updatedValues = new HashMap<>(); for (Iterator<String> renamedParameters = fixed.getParameterNamesIterator(); renamedParameters.hasNext(); ) { String solrParameter = renamedParameters.next(); if (solrParameter.endsWith("." + paramName)) { int value = Integer.valueOf(fixed.get(solrParameter)); updatedValues.put(solrParameter, Math.max(value, 1)); } } for (Map.Entry<String, Integer> updatedParameterValues : updatedValues.entrySet()) { fixed.set(updatedParameterValues.getKey(), updatedParameterValues.getValue()); } String paramValue = params.get(paramName); int value = 0; if (paramValue != null) { value = Integer.valueOf(paramValue); } fixed.set(paramName, Math.max(value, 1)); } }  }
RewriteFacetParametersComponent extends SearchComponent { protected void rewriteMincountFacetFieldOption(ModifiableSolrParams fixed, SolrParams params, String paramName, Map<String, String> fieldMappings, SolrQueryRequest req) { rewriteFacetFieldOptions(fixed, params, paramName, fieldMappings); String shardPurpose = req.getParams().get(ShardParams.SHARDS_PURPOSE); boolean isInitialDistributedRequest = (shardPurpose==null); if(isInitialDistributedRequest) { Map<String, Integer> updatedValues = new HashMap<>(); for (Iterator<String> renamedParameters = fixed.getParameterNamesIterator(); renamedParameters.hasNext(); ) { String solrParameter = renamedParameters.next(); if (solrParameter.endsWith("." + paramName)) { int value = Integer.valueOf(fixed.get(solrParameter)); updatedValues.put(solrParameter, Math.max(value, 1)); } } for (Map.Entry<String, Integer> updatedParameterValues : updatedValues.entrySet()) { fixed.set(updatedParameterValues.getKey(), updatedParameterValues.getValue()); } String paramValue = params.get(paramName); int value = 0; if (paramValue != null) { value = Integer.valueOf(paramValue); } fixed.set(paramName, Math.max(value, 1)); } }  @Override void prepare(ResponseBuilder rb); static String[] parseFacetField(String line); @Override void process(ResponseBuilder rb); @Override String getDescription(); @Override String getSource(); }
RewriteFacetParametersComponent extends SearchComponent { protected void rewriteMincountFacetFieldOption(ModifiableSolrParams fixed, SolrParams params, String paramName, Map<String, String> fieldMappings, SolrQueryRequest req) { rewriteFacetFieldOptions(fixed, params, paramName, fieldMappings); String shardPurpose = req.getParams().get(ShardParams.SHARDS_PURPOSE); boolean isInitialDistributedRequest = (shardPurpose==null); if(isInitialDistributedRequest) { Map<String, Integer> updatedValues = new HashMap<>(); for (Iterator<String> renamedParameters = fixed.getParameterNamesIterator(); renamedParameters.hasNext(); ) { String solrParameter = renamedParameters.next(); if (solrParameter.endsWith("." + paramName)) { int value = Integer.valueOf(fixed.get(solrParameter)); updatedValues.put(solrParameter, Math.max(value, 1)); } } for (Map.Entry<String, Integer> updatedParameterValues : updatedValues.entrySet()) { fixed.set(updatedParameterValues.getKey(), updatedParameterValues.getValue()); } String paramValue = params.get(paramName); int value = 0; if (paramValue != null) { value = Integer.valueOf(paramValue); } fixed.set(paramName, Math.max(value, 1)); } }  @Override void prepare(ResponseBuilder rb); static String[] parseFacetField(String line); @Override void process(ResponseBuilder rb); @Override String getDescription(); @Override String getSource();  }