use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class PointTypeValueSource method init.
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
SolrParams p = new MapSolrParams(args);
dimension = p.getInt(DIMENSION, DEFAULT_DIMENSION);
if (dimension < 1) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "The dimension must be > 0: " + dimension);
}
args.remove(DIMENSION);
super.init(schema, args);
// cache suffixes
createSuffixCache(dimension);
}
use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class SolrConfigHandler method setWt.
public static void setWt(SolrQueryRequest req, String wt) {
SolrParams params = req.getParams();
//wt is set by user
if (params.get(CommonParams.WT) != null)
return;
Map<String, String> map = new HashMap<>(1);
map.put(CommonParams.WT, wt);
map.put("indent", "true");
req.setParams(SolrParams.wrapDefaults(params, new MapSolrParams(map)));
}
use of org.apache.solr.common.params.MapSolrParams in project lucene-solr by apache.
the class AbstractSubTypeFieldType method init.
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
super.init(schema, args);
this.schema = schema;
//it's not a first class citizen for the IndexSchema
SolrParams p = new MapSolrParams(args);
subFieldType = p.get(SUB_FIELD_TYPE);
subSuffix = p.get(SUB_FIELD_SUFFIX);
if (subFieldType != null) {
args.remove(SUB_FIELD_TYPE);
subType = schema.getFieldTypeByName(subFieldType.trim());
suffix = POLY_FIELD_SEPARATOR + subType.typeName;
} else if (subSuffix != null) {
args.remove(SUB_FIELD_SUFFIX);
suffix = subSuffix;
} else {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "The field type: " + typeName + " must specify the " + SUB_FIELD_TYPE + " attribute or the " + SUB_FIELD_SUFFIX + " attribute.");
}
}
use of org.apache.solr.common.params.MapSolrParams in project xwiki-platform by xwiki.
the class XWikiDismaxQParserPluginTest method withFieldAliases.
@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"));
// Event if this field doesn't appear in the query, it's a default field so it has to have the alias.
assertEquals("comment__ comment_en comment_fr comment_zh_TW", paramsWithAliases.get("f.comment.qf"));
// These fields are not declared as multilingual.
assertNull(paramsWithAliases.get("f.x.qf"));
assertNull(paramsWithAliases.get("f.title_ro.qf"));
// This is a default field but it's not declared as multilingual.
assertNull(paramsWithAliases.get("f.date.qf"));
// This multilingual field doesn't appear in the query and it's not a default field either.
assertNull(paramsWithAliases.get("f.foo.qf"));
}
use of org.apache.solr.common.params.MapSolrParams in project xwiki-platform by xwiki.
the class XWikiDismaxQParserPluginTest method withFieldAliasesWhenNoMultilingualFields.
@Test
public void withFieldAliasesWhenNoMultilingualFields() {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("qf", "title^0.4 comment^0.40 date^1.0");
parameters.put("xwiki.supportedLocales", "en, ro");
SolrParams paramsWithAliases = plugin.withFieldAliases("title:text", new MapSolrParams(parameters));
// The existing parameters should have been preserved.
assertEquals(2, paramsWithAliases.toNamedList().size());
assertEquals("title^0.4 comment^0.40 date^1.0", paramsWithAliases.get("qf"));
assertEquals("en, ro", paramsWithAliases.get("xwiki.supportedLocales"));
}
Aggregations