Java Code Examples for org.apache.solr.common.params.SolrParams#toSolrParams()
The following examples show how to use
org.apache.solr.common.params.SolrParams#toSolrParams() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WiseOwlQParserPlugin.java From wiseowl with MIT License | 5 votes |
@SuppressWarnings("rawtypes") public void init(NamedList initArgs) { SolrParams params = SolrParams.toSolrParams(initArgs); String modelDirectory = params.get("modelDirectory", System.getProperty("model.dir"));//<co id="qqpp.model"/> String wordnetDirectory = params.get("wordnetDirectory", System.getProperty("wordnet.dir"));//<co id="qqpp.wordnet"/> if (modelDirectory != null) { File modelsDir = new File(modelDirectory); try { InputStream chunkerStream = new FileInputStream( new File(modelsDir,"en-chunker.bin")); ChunkerModel chunkerModel = new ChunkerModel(chunkerStream); chunker = new ChunkerME(chunkerModel); //<co id="qqpp.chunker"/> InputStream posStream = new FileInputStream( new File(modelsDir,"en-pos-maxent.bin")); POSModel posModel = new POSModel(posStream); tagger = new POSTaggerME(posModel); //<co id="qqpp.tagger"/> // model = new DoccatModel(new FileInputStream( //<co id="qqpp.theModel"/> // new File(modelDirectory,"en-answer.bin"))).getMaxentModel(); model = new SuffixSensitiveGISModelReader(new File(modelDirectory+"/qa/ans.bin")).getModel(); //GISModel m = new SuffixSensitiveGISModelReader(new File(modelFileName)).getModel(); probs = new double[model.getNumOutcomes()]; atcg = new AnswerTypeContextGenerator( new File(wordnetDirectory, "dict"));//<co id="qqpp.context"/> } catch (IOException e) { throw new RuntimeException(e); } } }
Example 2
Source File: FacetParser.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Helper that handles the possibility of map values being lists * NOTE: does *NOT* fail on map values that are sub-maps (ie: nested json objects) */ @SuppressWarnings({"unchecked", "rawtypes"}) public static SolrParams jsonToSolrParams(Map jsonObject) { // HACK, but NamedList already handles the list processing for us... NamedList<String> nl = new NamedList<>(); nl.addAll(jsonObject); return SolrParams.toSolrParams(nl); }
Example 3
Source File: TestMinHashQParser.java From lucene-solr with Apache License 2.0 | 5 votes |
private SolrQueryRequest createRequest(String query) { SolrQueryRequest qr = req(query); NamedList<Object> par = qr.getParams().toNamedList(); par.add("debug", "false"); par.add("rows", "30"); par.add("fl", "id,score"); par.remove("qt"); SolrParams newp = SolrParams.toSolrParams(par); qr.setParams(newp); return qr; }
Example 4
Source File: RemoveTrailingUnderscoreProcessorFactory.java From apache-solr-essentials with Apache License 2.0 | 5 votes |
@Override public void init(@SuppressWarnings("rawtypes") final NamedList args) { // 1. Solr utility to transform a generic named list in a set of SolrParams final SolrParams parameters = SolrParams.toSolrParams(args); // 2. Retrieve the names of the fields that will be checked by the processor fields = parameters.get("fields","").split(","); }
Example 5
Source File: OntologyUpdateProcessorFactory.java From BioSolr with Apache License 2.0 | 5 votes |
@Override public void init(@SuppressWarnings("rawtypes") final NamedList args) { if (args != null) { SolrParams params = SolrParams.toSolrParams(args); this.enabled = params.getBool(ENABLED_PARAM, true); if (enabled) { // Helper factory validates ontology parameters this.helperFactory = new SolrOntologyHelperFactory(params); } this.annotationField = params.get(ANNOTATION_FIELD_PARAM); this.fieldPrefix = params.get(FIELDNAME_PREFIX_PARAM, annotationField + "_"); this.labelField = params.get(LABEL_FIELD_PARAM, fieldPrefix + LABEL_FIELD_DEFAULT); this.uriFieldSuffix = params.get(URI_FIELD_SUFFIX_PARAM, URI_FIELD_SUFFIX); this.labelFieldSuffix = params.get(LABEL_FIELD_SUFFIX_PARAM, LABEL_FIELD_SUFFIX); String childField = params.get(CHILD_FIELD_PARAM, fieldPrefix + CHILD_FIELD_DEFAULT); this.childUriField = childField + uriFieldSuffix; this.childLabelField = childField + labelFieldSuffix; String parentField = params.get(PARENT_FIELD_PARAM, fieldPrefix + PARENT_FIELD_DEFAULT); this.parentUriField = parentField + uriFieldSuffix; this.parentLabelField = parentField + labelFieldSuffix; this.includeIndirect = params.getBool(INCLUDE_INDIRECT_PARAM, true); String descendentField = params.get(DESCENDANT_FIELD_PARAM, fieldPrefix + DESCENDANT_FIELD_DEFAULT); this.descendantUriField = descendentField + uriFieldSuffix; this.descendantLabelField = descendentField + labelFieldSuffix; String ancestorField = params.get(ANCESTOR_FIELD_PARAM, fieldPrefix + ANCESTOR_FIELD_DEFAULT); this.ancestorUriField = ancestorField + uriFieldSuffix; this.ancestorLabelField = ancestorField + labelFieldSuffix; this.includeRelations = params.getBool(INCLUDE_RELATIONS_PARAM, true); this.synonymsField = params.get(SYNONYMS_FIELD_PARAM, fieldPrefix + SYNONYMS_FIELD_DEFAULT); this.definitionField = params.get(DEFINITION_FIELD_PARAM, fieldPrefix + DEFINITION_FIELD_DEFAULT); this.includeParentPaths = params.getBool(PARENT_PATHS_PARAM, false); this.includeParentPathLabels = params.getBool(PARENT_PATHS_LABEL_PARAM, false); this.parentPathsField = params.get(PARENT_PATHS_FIELD_PARAM, PARENT_PATHS_FIELD_DEFAULT); } }
Example 6
Source File: QueryDocAuthorizationComponent.java From incubator-sentry with Apache License 2.0 | 5 votes |
@Override public void init(NamedList args) { SolrParams params = SolrParams.toSolrParams(args); this.authField = params.get(AUTH_FIELD_PROP, DEFAULT_AUTH_FIELD); log.info("QueryDocAuthorizationComponent authField: " + this.authField); this.allRolesToken = params.get(ALL_ROLES_TOKEN_PROP, ""); log.info("QueryDocAuthorizationComponent allRolesToken: " + this.allRolesToken); this.enabled = params.getBool(ENABLED_PROP, false); log.info("QueryDocAuthorizationComponent enabled: " + this.enabled); }
Example 7
Source File: RealTimePriceComponent.java From apache-solr-essentials with Apache License 2.0 | 4 votes |
/** * Component initialisation. */ @SuppressWarnings("rawtypes") @Override public void init(final NamedList args) { // 1.Retrieve the configuration parameters. // First a "dummy" mode flag, which indicates we are running the // example without a database. // If the dummy mode is set to true the get the datasource name // This component uses a database as external resource, but it could be // also a web service. In any case, this is the place where that // resource should be initialized. final SolrParams params = SolrParams.toSolrParams(args); final boolean isInDummyMode = params.getBool("dummy-mode", true); if (isInDummyMode) { hasBeenCorrectlyInitialised = true; return; } final String datasourceName = params.get("datasource-jndi-name", "jdbc/pricesdb"); // In case you want give a try, this component actually stubs its // behaviour. // This is because otherwise we should have a database somewhere, we // should configure a datasource and so on... // The following code is therefore commented and should be used in case // you set up a valid datasource try { // 2. Obtain a reference to the naming context final Context ctx = new InitialContext(); // 3. Lookup the datasource. datasource = (DataSource) ctx.lookup(datasourceName); // 4. Give a try by opening and immediately opening a connection. datasource.getConnection().close(); // 5a. Mark this component as valid hasBeenCorrectlyInitialised = false; } catch (final Exception exception) { exception.printStackTrace(); // 5b. Mark this component as invalid (no strictly needed) hasBeenCorrectlyInitialised = false; } }