@Test public void withFieldAliases() { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("qf", "title^0.4 comment^0.40 date^1.0"); parameters.put("xwiki.multilingualFields", "title, property.*, foo, comment"); parameters.put("xwiki.supportedLocales", "en, fr, zh_TW"); parameters.put("xwiki.typedDynamicFields", "property.*"); parameters.put("xwiki.dynamicFieldTypes", "boolean, int"); String query = "title:text AND x:y AND property.Blog.BlogPostClass.summary:wiki AND title_ro:value"; SolrParams paramsWithAliases = plugin.withFieldAliases(query, new MapSolrParams(parameters)); assertEquals("title__ title_en title_fr title_zh_TW", paramsWithAliases.get("f.title.qf")); assertEquals("property.Blog.BlogPostClass.summary__ property.Blog.BlogPostClass.summary_en " + "property.Blog.BlogPostClass.summary_fr property.Blog.BlogPostClass.summary_zh_TW " + "property.Blog.BlogPostClass.summary_boolean property.Blog.BlogPostClass.summary_int", paramsWithAliases.get("f.property.Blog.BlogPostClass.summary.qf")); assertEquals("comment__ comment_en comment_fr comment_zh_TW", paramsWithAliases.get("f.comment.qf")); assertNull(paramsWithAliases.get("f.x.qf")); assertNull(paramsWithAliases.get("f.title_ro.qf")); assertNull(paramsWithAliases.get("f.date.qf")); assertNull(paramsWithAliases.get("f.foo.qf")); }
public SolrParams withFieldAliases(String query, SolrParams parameters) { Set<String> fieldNames = extractFieldNames(query); String defaultQueryFields = parameters.get("qf"); if (defaultQueryFields != null) { fieldNames.addAll(SolrPluginUtils.parseFieldBoosts(defaultQueryFields).keySet()); } if (fieldNames.isEmpty()) { return parameters; } Map<String, String> aliasParameters = new HashMap<String, String>(); addMultilingualFieldAliases(fieldNames, aliasParameters, parameters); addTypedDynamicFieldAliases(fieldNames, aliasParameters, parameters); return aliasParameters.isEmpty() ? parameters : SolrParams.wrapDefaults(new MapSolrParams(aliasParameters), parameters); }
XWikiDismaxQParserPlugin extends ExtendedDismaxQParserPlugin { public SolrParams withFieldAliases(String query, SolrParams parameters) { Set<String> fieldNames = extractFieldNames(query); String defaultQueryFields = parameters.get("qf"); if (defaultQueryFields != null) { fieldNames.addAll(SolrPluginUtils.parseFieldBoosts(defaultQueryFields).keySet()); } if (fieldNames.isEmpty()) { return parameters; } Map<String, String> aliasParameters = new HashMap<String, String>(); addMultilingualFieldAliases(fieldNames, aliasParameters, parameters); addTypedDynamicFieldAliases(fieldNames, aliasParameters, parameters); return aliasParameters.isEmpty() ? parameters : SolrParams.wrapDefaults(new MapSolrParams(aliasParameters), parameters); } }
XWikiDismaxQParserPlugin extends ExtendedDismaxQParserPlugin { public SolrParams withFieldAliases(String query, SolrParams parameters) { Set<String> fieldNames = extractFieldNames(query); String defaultQueryFields = parameters.get("qf"); if (defaultQueryFields != null) { fieldNames.addAll(SolrPluginUtils.parseFieldBoosts(defaultQueryFields).keySet()); } if (fieldNames.isEmpty()) { return parameters; } Map<String, String> aliasParameters = new HashMap<String, String>(); addMultilingualFieldAliases(fieldNames, aliasParameters, parameters); addTypedDynamicFieldAliases(fieldNames, aliasParameters, parameters); return aliasParameters.isEmpty() ? parameters : SolrParams.wrapDefaults(new MapSolrParams(aliasParameters), parameters); }  }
XWikiDismaxQParserPlugin extends ExtendedDismaxQParserPlugin { public SolrParams withFieldAliases(String query, SolrParams parameters) { Set<String> fieldNames = extractFieldNames(query); String defaultQueryFields = parameters.get("qf"); if (defaultQueryFields != null) { fieldNames.addAll(SolrPluginUtils.parseFieldBoosts(defaultQueryFields).keySet()); } if (fieldNames.isEmpty()) { return parameters; } Map<String, String> aliasParameters = new HashMap<String, String>(); addMultilingualFieldAliases(fieldNames, aliasParameters, parameters); addTypedDynamicFieldAliases(fieldNames, aliasParameters, parameters); return aliasParameters.isEmpty() ? parameters : SolrParams.wrapDefaults(new MapSolrParams(aliasParameters), parameters); }  @Override QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req); SolrParams withFieldAliases(String query, SolrParams parameters); Set<String> extractFieldNames(String query); }
XWikiDismaxQParserPlugin extends ExtendedDismaxQParserPlugin { public SolrParams withFieldAliases(String query, SolrParams parameters) { Set<String> fieldNames = extractFieldNames(query); String defaultQueryFields = parameters.get("qf"); if (defaultQueryFields != null) { fieldNames.addAll(SolrPluginUtils.parseFieldBoosts(defaultQueryFields).keySet()); } if (fieldNames.isEmpty()) { return parameters; } Map<String, String> aliasParameters = new HashMap<String, String>(); addMultilingualFieldAliases(fieldNames, aliasParameters, parameters); addTypedDynamicFieldAliases(fieldNames, aliasParameters, parameters); return aliasParameters.isEmpty() ? parameters : SolrParams.wrapDefaults(new MapSolrParams(aliasParameters), parameters); }  @Override QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req); SolrParams withFieldAliases(String query, SolrParams parameters); Set<String> extractFieldNames(String query);  }