protected boolean isTestForHits() { final Boolean doTest = getArgs().getBooleanArg(CONF_TEST_FOR_HITS); return doTest != null && doTest; }
@Override public RewriterFactory createRewriterFactory(NamedList<?> args, ResourceLoader resourceLoader) throws IOException { Boolean acceptGeneratedTerms = args.getBooleanArg("acceptGeneratedTerms"); boolean t = (acceptGeneratedTerms == null) ? false : acceptGeneratedTerms; return new querqy.rewrite.contrib.ShingleRewriterFactory(t); } }
/** * Used for getting a boolean argument from a NamedList object. If the name * is not present, returns null. If there is more than one value with that * name, or if the value found is not a Boolean or a String, throws an * exception. If there is only one value present and it is a Boolean or a * String, the value is removed and returned as a Boolean. If an exception * is thrown, the NamedList is not modified. See {@link #removeAll(String)} * and {@link #removeConfigArgs(String)} for additional ways of gathering * configuration information from a NamedList. * * @param name * The key to look up in the NamedList. * @return The boolean value found. * @throws SolrException * If multiple values are found for the name or the value found is * not a Boolean or a String. */ public Boolean removeBooleanArg(final String name) { Boolean bool = getBooleanArg(name); if (null != bool) { remove(name); } return bool; }
/** * Used for getting a boolean argument from a NamedList object. If the name * is not present, returns null. If there is more than one value with that * name, or if the value found is not a Boolean or a String, throws an * exception. If there is only one value present and it is a Boolean or a * String, the value is removed and returned as a Boolean. If an exception * is thrown, the NamedList is not modified. See {@link #removeAll(String)} * and {@link #removeConfigArgs(String)} for additional ways of gathering * configuration information from a NamedList. * * @param name * The key to look up in the NamedList. * @return The boolean value found. * @throws SolrException * If multiple values are found for the name or the value found is * not a Boolean or a String. */ public Boolean removeBooleanArg(final String name) { Boolean bool = getBooleanArg(name); if (null != bool) { remove(name); } return bool; }
@Override public void init(final NamedList args) { qnamesFile = (String) args.get(SirenParams.QNAMES); if (args.get(SirenParams.ALLOW_LEADING_WILDCARD) != null) { allowLeadingWildcard = args.getBooleanArg(SirenParams.ALLOW_LEADING_WILDCARD); } }
Boolean prle = args.getBooleanArg(PARAMS_RESOURCE_LOADER_ENABLED); paramsResourceLoaderEnabled = (null == prle ? false : prle); Boolean srle = args.getBooleanArg(SOLR_RESOURCE_LOADER_ENABLED); solrResourceLoaderEnabled = (null == srle ? true : srle);
@Override public void inform(final ResourceLoader loader) throws IOException { rewriteChain = loadRewriteChain(loader); termQueryCacheName = (String) initArgs.get(CONF_CACHE_NAME); final Boolean updateCache = initArgs.getBooleanArg(CONF_CACHE_UPDATE); if (termQueryCacheName == null && updateCache != null) { throw new IOException("Configuration property " + CONF_CACHE_NAME + " required if " + CONF_CACHE_UPDATE + " is set"); } ignoreTermQueryCacheUpdates = (updateCache != null) && !updateCache; this.querqyParserFactory = loadSolrQuerqyParserFactory(loader, initArgs); }
@Override public RewriterFactory createRewriterFactory(NamedList<?> args, ResourceLoader resourceLoader) throws IOException { Boolean expand = args.getBooleanArg("expand"); if (expand == null) { expand = false; } Boolean ignoreCase = args.getBooleanArg("ignoreCase"); if (ignoreCase == null) { ignoreCase = true; } String synonymResoureName = (String) args.get("synonyms"); if (synonymResoureName == null) { throw new IllegalArgumentException("Property 'synonyms' not configured"); } LuceneSynonymsRewriterFactory factory = new LuceneSynonymsRewriterFactory(expand, ignoreCase); for (String resource : synonymResoureName.split(",")) { resource = resource.trim(); if (resource.length() > 0) { factory.addResource(resourceLoader.openResource(resource)); } } factory.build(); return factory; }
@Override public RewriterFactory createRewriterFactory(final NamedList<?> args, final ResourceLoader resourceLoader) throws IOException { final String rulesResourceName = (String) args.get("rules"); if (rulesResourceName == null) { throw new IllegalArgumentException("Property 'rules' not configured"); } final Boolean ignoreCase = args.getBooleanArg("ignoreCase"); // querqy parser for queries that are part of the instructions in the // rules String rulesQuerqyParser = (String) args.get("querqyParser"); QuerqyParserFactory querqyParser = null; if (rulesQuerqyParser != null) { rulesQuerqyParser = rulesQuerqyParser.trim(); if (rulesQuerqyParser.length() > 0) { querqyParser = resourceLoader.newInstance(rulesQuerqyParser, QuerqyParserFactory.class); } } if (querqyParser == null) { querqyParser = new WhiteSpaceQuerqyParserFactory(); } return new querqy.rewrite.commonrules.SimpleCommonRulesRewriterFactory( new InputStreamReader(resourceLoader.openResource(rulesResourceName), "UTF-8"), querqyParser, ignoreCase == null || ignoreCase); }
@Override public void doWrite( final NamedList response, final Writer writer, final String contentType) { final Boolean askResult = response.getBooleanArg(Names.QUERY_RESULT); if (WebContent.contentTypeTextCSV.equals(contentType) || WebContent.contentTypeTextPlain.equals(contentType)) { ResultSetFormatter.outputAsCSV(new WriterOutputStream(writer, CharacterSet.UTF_8), askResult); } else if (WebContent.contentTypeTextTSV.equals(contentType)) { ResultSetFormatter.outputAsTSV(new WriterOutputStream(writer, CharacterSet.UTF_8), askResult); } else if (ResultSetLang.SPARQLResultSetXML.getHeaderString().equals(contentType)) { ResultSetFormatter.outputAsXML(new WriterOutputStream(writer, CharacterSet.UTF_8), askResult); } else if (ResultSetLang.SPARQLResultSetJSON.getHeaderString().equals(contentType)) { ResultSetFormatter.outputAsJSON(new WriterOutputStream(writer, CharacterSet.UTF_8), askResult); } } });
if ("engine".equals(entry.getKey())) { NamedList<Object> engineInitParams = (NamedList<Object>) entry.getValue(); Boolean optional = engineInitParams.getBooleanArg("optional"); optional = (optional == null ? Boolean.FALSE : optional);
@Override public RewriterFactory createRewriterFactory(NamedList<?> args, ResourceLoader resourceLoader) throws IOException { String boostUp = (String) args.get("boostUp"); String boostDown = (String) args.get("boostDown"); Boolean ignoreCase = args.getBooleanArg("ignoreCase"); if ((boostUp == null) && (boostDown == null)) { // remove this check when we load other instruction types throw new IllegalArgumentException("At least on of boostUp or boostDown must be configured"); } RulesCollectionBuilder builder = new TrieMapRulesCollectionBuilder(ignoreCase != null && ignoreCase); if (boostUp != null) { addBoostInstructions(builder, BoostDirection.UP, 1f, resourceLoader, boostUp); } if (boostDown != null) { addBoostInstructions(builder, BoostDirection.DOWN, 1f, resourceLoader, boostDown); } return new RulesRewriterFactory(builder.build()); }