/** * Get the value of any boost factor for the mapped name. * * @param name The name of the field to see if there is a boost specified * @return The boost value */ protected float getBoost(String name) { return params.getFloat(BOOST_PREFIX + name, 1.0f); }
@Override public float getFloat(String param, float def) { return params.getFloat(param, def); }
@Override public float getFloat(String param, float def) { return params.getFloat(param, def); }
@Override public float getFloat(String param, float def) { return params.getFloat(param, def); }
private Float getAlpha(SolrParams params){ return params.getFloat(ALPHA, this.dfltAlpha); }
/** * <p>Get an optional tiebreaker for combining phrase boosts.</p> * * <p>When query (sub)phrase boosting is enabled via {@link #getPhraseBoostFieldParams()}, phrases could be boosted * several times if boosting is enabled for query term bi-grams, tri-grams and the entire phrase because the bi-grams * would be contained in the tri-grams and the tri-grams would be contained in the exact query phrase. * The {@link PhraseBoosting#makePhraseFieldsBoostQuery(QuerqyQuery, List, float, Analyzer)} combines * the boost queries for the different n-gram/phrase levels using * a {@link org.apache.lucene.search.DisjunctionMaxQuery}. This tiebreaker controls how much weight is given to the * n-gram/phrase level with the highest score vs the other n-gram/phrase levels. A tiebreaker value of * 0.0 would disable all phrase boostings except for the highest scoring n-gram/phrase level. A value of 1.0 would * sum up the phrase boosts of all levels, which would be the behaviour of the pf, pf2, pf3 params in Solr's * edismax query parser.</p> * * @see #getPhraseBoostFieldParams() * @return The value of request parameter {@value QuerqyDismaxParams#QPF_TIE}, defaults to {@value #DEFAULT_QPF_TIE} */ public float getPhraseBoostTiebreaker() { return solrParams.getFloat(QPF_TIE, DEFAULT_QPF_TIE); }
@Override public Optional<Float> getFloatRequestParam(final String name) { return Optional.ofNullable(solrParams.getFloat(name)); }
public void init(SolrParams params) { quantRate = params.getFloat("quantRate", 0.01f); minTokenLen = params.getInt("minTokenLen", 2); }
private Query attemptToApplySynonymsToQuery(Query query, SolrParams solrParams, Analyzer synonymAnalyzer) throws IOException { List<Query> synonymQueries = generateSynonymQueries(synonymAnalyzer, solrParams); boolean ignoreQueryOperators = solrParams.getBool(Params.SYNONYMS_IGNORE_QUERY_OPERATORS, false); boolean hasComplexQueryOperators = ignoreQueryOperators ? false : Const.COMPLEX_QUERY_OPERATORS_PATTERN.matcher(getQueryStringFromParser()).find(); if (hasComplexQueryOperators) { // TODO: support complex operators reasonForNotExpandingSynonyms = ReasonForNotExpandingSynonyms.HasComplexQueryOperators; return query; } else if (synonymQueries.isEmpty()) { // didn't find more than 0 synonyms, i.e. it's just the original phrase reasonForNotExpandingSynonyms = ReasonForNotExpandingSynonyms.DidntFindAnySynonyms; return query; } float originalBoost = solrParams.getFloat(Params.SYNONYMS_ORIGINAL_BOOST, 1.0F); float synonymBoost = solrParams.getFloat(Params.SYNONYMS_SYNONYM_BOOST, 1.0F); query = applySynonymQueries(query, synonymQueries, originalBoost, synonymBoost); return query; }
/** Returns a dictionary to be used when building the spell-checker index. * Override the method for custom dictionary */ protected Dictionary getDictionary(SolrQueryRequest req) { float threshold; try { threshold = req.getParams().getFloat(THRESHOLD, DEFAULT_DICTIONARY_THRESHOLD); } catch (NumberFormatException e) { throw new RuntimeException("Threshold must be a valid positive float", e); } IndexReader indexReader = req.getSearcher().getReader(); return new HighFrequencyDictionary(indexReader, termSourceField, threshold); }
protected void addMainQuery(BooleanQuery query, SolrParams solrParams) throws ParseException { Map<String, Float> phraseFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.PF)); float tiebreaker = solrParams.getFloat(DisMaxParams.TIE, 0.0f); /* a parser for dealing with user input, which will convert * things to DisjunctionMaxQueries */ SolrPluginUtils.DisjunctionMaxQueryParser up = getParser(queryFields, DisMaxParams.QS, solrParams, tiebreaker); /* for parsing sloppy phrases using DisjunctionMaxQueries */ SolrPluginUtils.DisjunctionMaxQueryParser pp = getParser(phraseFields, DisMaxParams.PS, solrParams, tiebreaker); /* * * Main User Query * * */ parsedUserQuery = null; String userQuery = getString(); altUserQuery = null; if (userQuery == null || userQuery.trim().length() < 1) { // If no query is specified, we may have an alternate altUserQuery = getAlternateUserQuery(solrParams); query.add(altUserQuery, BooleanClause.Occur.MUST); } else { // There is a valid query string userQuery = SolrPluginUtils.partialEscape(SolrPluginUtils.stripUnbalancedQuotes(userQuery)).toString(); userQuery = SolrPluginUtils.stripIllegalOperators(userQuery).toString(); parsedUserQuery = getUserQuery(userQuery, up, solrParams); query.add(parsedUserQuery, BooleanClause.Occur.MUST); Query phrase = getPhraseQuery(userQuery, pp); if (null != phrase) { query.add(phrase, BooleanClause.Occur.SHOULD); } } }
Map<String, Float> bigramWeights = new HashMap<String, Float>(); createWeights(params.get(CommonParams.Q), sQuery, termWeights, bigramWeights, reader); float adjWeight = params.getFloat(ADJACENT_WEIGHT, DEFAULT_ADJACENT_WEIGHT); float secondAdjWeight = params.getFloat(SECOND_ADJ_WEIGHT, DEFAULT_SECOND_ADJACENT_WEIGHT); float bigramWeight = params.getFloat(BIGRAM_WEIGHT, DEFAULT_BIGRAM_WEIGHT);
boolean extendedResults = params.getBool(SPELLCHECK_EXTENDED_RESULTS, false); boolean collate = params.getBool(SPELLCHECK_COLLATE, false); float accuracy = params.getFloat(SPELLCHECK_ACCURACY, Float.MIN_VALUE); Integer alternativeTermCount = params.getInt(SpellingParams.SPELLCHECK_ALTERNATIVE_TERM_COUNT); Integer maxResultsForSuggest = params.getInt(SpellingParams.SPELLCHECK_MAX_RESULTS_FOR_SUGGEST);