@Test public void testEnhanceParamsDoesntReplaceExistingValues() { SolrQuery input = new SolrQuery("field:value"); input.set(CommonParams.FL, "id"); input.setStart(30); input.setRows(10); SolrQuery output = SolrQueryUtils.generateQuery(input, null); Assert.assertEquals("field:value", output.get(CommonParams.Q)); Assert.assertEquals("id", output.get(CommonParams.FL)); Assert.assertEquals(true, output.getBool(SpellingParams.SPELLCHECK_COLLATE)); Assert.assertEquals(30, (int) output.getInt(CommonParams.START)); Assert.assertEquals(10, (int) output.getInt(CommonParams.ROWS)); }
public static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions) { if (originalParams == null) { return null; } SolrQuery result = new SolrQuery(); result.setStart(0); result.setRows(1000); result.setIncludeScore(true); if (queryOptions != null) { for (Map.Entry<String, String> item : queryOptions.entrySet()) { result.set(item.getKey(), item.getValue()); } } for (Map.Entry<String, Object> item : originalParams.toNamedList()) { if (item.getValue() != null && item.getValue() instanceof String[]) { result.set(item.getKey(), (String[]) item.getValue()); } else { result.set(item.getKey(), String.valueOf(item.getValue())); } } if (result.get(SPELLCHECK) == null) { result.set(SPELLCHECK, Boolean.toString(true)); result.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true)); } return result; }
SolrQueryUtils { public static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions) { if (originalParams == null) { return null; } SolrQuery result = new SolrQuery(); result.setStart(0); result.setRows(1000); result.setIncludeScore(true); if (queryOptions != null) { for (Map.Entry<String, String> item : queryOptions.entrySet()) { result.set(item.getKey(), item.getValue()); } } for (Map.Entry<String, Object> item : originalParams.toNamedList()) { if (item.getValue() != null && item.getValue() instanceof String[]) { result.set(item.getKey(), (String[]) item.getValue()); } else { result.set(item.getKey(), String.valueOf(item.getValue())); } } if (result.get(SPELLCHECK) == null) { result.set(SPELLCHECK, Boolean.toString(true)); result.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true)); } return result; } }
SolrQueryUtils { public static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions) { if (originalParams == null) { return null; } SolrQuery result = new SolrQuery(); result.setStart(0); result.setRows(1000); result.setIncludeScore(true); if (queryOptions != null) { for (Map.Entry<String, String> item : queryOptions.entrySet()) { result.set(item.getKey(), item.getValue()); } } for (Map.Entry<String, Object> item : originalParams.toNamedList()) { if (item.getValue() != null && item.getValue() instanceof String[]) { result.set(item.getKey(), (String[]) item.getValue()); } else { result.set(item.getKey(), String.valueOf(item.getValue())); } } if (result.get(SPELLCHECK) == null) { result.set(SPELLCHECK, Boolean.toString(true)); result.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true)); } return result; } private  SolrQueryUtils(); }
SolrQueryUtils { public static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions) { if (originalParams == null) { return null; } SolrQuery result = new SolrQuery(); result.setStart(0); result.setRows(1000); result.setIncludeScore(true); if (queryOptions != null) { for (Map.Entry<String, String> item : queryOptions.entrySet()) { result.set(item.getKey(), item.getValue()); } } for (Map.Entry<String, Object> item : originalParams.toNamedList()) { if (item.getValue() != null && item.getValue() instanceof String[]) { result.set(item.getKey(), (String[]) item.getValue()); } else { result.set(item.getKey(), String.valueOf(item.getValue())); } } if (result.get(SPELLCHECK) == null) { result.set(SPELLCHECK, Boolean.toString(true)); result.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true)); } return result; } private  SolrQueryUtils(); static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions); static SolrQuery applySpellcheckSuggestion(SolrQuery originalQuery, String suggestedQuery); }
SolrQueryUtils { public static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions) { if (originalParams == null) { return null; } SolrQuery result = new SolrQuery(); result.setStart(0); result.setRows(1000); result.setIncludeScore(true); if (queryOptions != null) { for (Map.Entry<String, String> item : queryOptions.entrySet()) { result.set(item.getKey(), item.getValue()); } } for (Map.Entry<String, Object> item : originalParams.toNamedList()) { if (item.getValue() != null && item.getValue() instanceof String[]) { result.set(item.getKey(), (String[]) item.getValue()); } else { result.set(item.getKey(), String.valueOf(item.getValue())); } } if (result.get(SPELLCHECK) == null) { result.set(SPELLCHECK, Boolean.toString(true)); result.set(SpellingParams.SPELLCHECK_COLLATE, Boolean.toString(true)); } return result; } private  SolrQueryUtils(); static SolrQuery generateQuery(SolrQuery originalParams, Map<String, String> queryOptions); static SolrQuery applySpellcheckSuggestion(SolrQuery originalQuery, String suggestedQuery);  }