Search in sources :

Example 46 with MapSolrParams

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);
}
Also used : MapSolrParams(org.apache.solr.common.params.MapSolrParams) SolrParams(org.apache.solr.common.params.SolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams) SolrException(org.apache.solr.common.SolrException)

Example 47 with MapSolrParams

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)));
}
Also used : MapSolrParams(org.apache.solr.common.params.MapSolrParams) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SolrParams(org.apache.solr.common.params.SolrParams) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams) StrUtils.formatString(org.apache.solr.common.util.StrUtils.formatString)

Example 48 with MapSolrParams

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.");
    }
}
Also used : MapSolrParams(org.apache.solr.common.params.MapSolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams) SolrParams(org.apache.solr.common.params.SolrParams) SolrException(org.apache.solr.common.SolrException)

Example 49 with MapSolrParams

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"));
}
Also used : MapSolrParams(org.apache.solr.common.params.MapSolrParams) HashMap(java.util.HashMap) MapSolrParams(org.apache.solr.common.params.MapSolrParams) SolrParams(org.apache.solr.common.params.SolrParams) Test(org.junit.Test)

Example 50 with MapSolrParams

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"));
}
Also used : MapSolrParams(org.apache.solr.common.params.MapSolrParams) HashMap(java.util.HashMap) MapSolrParams(org.apache.solr.common.params.MapSolrParams) SolrParams(org.apache.solr.common.params.SolrParams) Test(org.junit.Test)

Aggregations

MapSolrParams (org.apache.solr.common.params.MapSolrParams)50 HashMap (java.util.HashMap)33 SolrCore (org.apache.solr.core.SolrCore)24 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)20 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)19 SolrParams (org.apache.solr.common.params.SolrParams)14 Test (org.junit.Test)14 LinkedHashMap (java.util.LinkedHashMap)11 ArrayList (java.util.ArrayList)10 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)10 SolrException (org.apache.solr.common.SolrException)6 UpdateRequestHandler (org.apache.solr.handler.UpdateRequestHandler)6 SolrQueryRequestBase (org.apache.solr.request.SolrQueryRequestBase)6 Map (java.util.Map)4 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)4 Utils.makeMap (org.apache.solr.common.util.Utils.makeMap)4 IOException (java.io.IOException)3 SchemaField (org.apache.solr.schema.SchemaField)3 StringWriter (java.io.StringWriter)2 Collections.singletonMap (java.util.Collections.singletonMap)2