You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by bo...@apache.org on 2015/03/18 00:33:27 UTC
[05/17] incubator-ranger git commit: Support for Solr as Audit
Destination.
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/FacetParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/FacetParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/FacetParams.java
new file mode 100644
index 0000000..2dae65f
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/FacetParams.java
@@ -0,0 +1,405 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import java.util.EnumSet;
+import java.util.Locale;
+
+import org.apache.solr.common.SolrException;
+
+/**
+ * Facet parameters
+ */
+public interface FacetParams {
+
+ /**
+ * Should facet counts be calculated?
+ */
+ public static final String FACET = "facet";
+
+ /**
+ * Numeric option indicating the maximum number of threads to be used
+ * in counting facet field vales
+ */
+ public static final String FACET_THREADS = FACET + ".threads";
+
+ /** What method should be used to do the faceting */
+ public static final String FACET_METHOD = FACET + ".method";
+
+ /** Value for FACET_METHOD param to indicate that Solr should enumerate over terms
+ * in a field to calculate the facet counts.
+ */
+ public static final String FACET_METHOD_enum = "enum";
+
+ /** Value for FACET_METHOD param to indicate that Solr should enumerate over documents
+ * and count up terms by consulting an uninverted representation of the field values
+ * (such as the FieldCache used for sorting).
+ */
+ public static final String FACET_METHOD_fc = "fc";
+
+ /** Value for FACET_METHOD param, like FACET_METHOD_fc but counts per-segment.
+ */
+ public static final String FACET_METHOD_fcs = "fcs";
+
+ /**
+ * Any lucene formated queries the user would like to use for
+ * Facet Constraint Counts (multi-value)
+ */
+ public static final String FACET_QUERY = FACET + ".query";
+ /**
+ * Any field whose terms the user wants to enumerate over for
+ * Facet Constraint Counts (multi-value)
+ */
+ public static final String FACET_FIELD = FACET + ".field";
+
+ /**
+ * The offset into the list of facets.
+ * Can be overridden on a per field basis.
+ */
+ public static final String FACET_OFFSET = FACET + ".offset";
+
+ /**
+ * Numeric option indicating the maximum number of facet field counts
+ * be included in the response for each field - in descending order of count.
+ * Can be overridden on a per field basis.
+ */
+ public static final String FACET_LIMIT = FACET + ".limit";
+
+ /**
+ * Numeric option indicating the minimum number of hits before a facet should
+ * be included in the response. Can be overridden on a per field basis.
+ */
+ public static final String FACET_MINCOUNT = FACET + ".mincount";
+
+ /**
+ * Boolean option indicating whether facet field counts of "0" should
+ * be included in the response. Can be overridden on a per field basis.
+ */
+ public static final String FACET_ZEROS = FACET + ".zeros";
+
+ /**
+ * Boolean option indicating whether the response should include a
+ * facet field count for all records which have no value for the
+ * facet field. Can be overridden on a per field basis.
+ */
+ public static final String FACET_MISSING = FACET + ".missing";
+
+
+ static final String FACET_OVERREQUEST = FACET + ".overrequest";
+
+ /**
+ * The percentage to over-request by when performing initial distributed requests.
+ *
+ * default value is 1.5
+ */
+ public static final String FACET_OVERREQUEST_RATIO = FACET_OVERREQUEST + ".ratio";
+
+ /**
+ * An additional amount to over-request by when performing initial distributed requests. This
+ * value will be added after accounting for the over-request ratio.
+ *
+ * default value is 10
+ */
+ public static final String FACET_OVERREQUEST_COUNT = FACET_OVERREQUEST + ".count";
+
+
+ /**
+ * Comma separated list of fields to pivot
+ *
+ * example: author,type (for types by author / types within author)
+ */
+ public static final String FACET_PIVOT = FACET + ".pivot";
+
+ /**
+ * Minimum number of docs that need to match to be included in the sublist
+ *
+ * default value is 1
+ */
+ public static final String FACET_PIVOT_MINCOUNT = FACET_PIVOT + ".mincount";
+
+
+ /**
+ * String option: "count" causes facets to be sorted
+ * by the count, "index" results in index order.
+ */
+ public static final String FACET_SORT = FACET + ".sort";
+
+ public static final String FACET_SORT_COUNT = "count";
+ public static final String FACET_SORT_COUNT_LEGACY = "true";
+ public static final String FACET_SORT_INDEX = "index";
+ public static final String FACET_SORT_INDEX_LEGACY = "false";
+
+ /**
+ * Only return constraints of a facet field with the given prefix.
+ */
+ public static final String FACET_PREFIX = FACET + ".prefix";
+
+ /**
+ * When faceting by enumerating the terms in a field,
+ * only use the filterCache for terms with a df >= to this parameter.
+ */
+ public static final String FACET_ENUM_CACHE_MINDF = FACET + ".enum.cache.minDf";
+ /**
+ * Any field whose terms the user wants to enumerate over for
+ * Facet Contraint Counts (multi-value)
+ */
+ public static final String FACET_DATE = FACET + ".date";
+ /**
+ * Date string indicating the starting point for a date facet range.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_DATE_START = FACET_DATE + ".start";
+ /**
+ * Date string indicating the endinging point for a date facet range.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_DATE_END = FACET_DATE + ".end";
+ /**
+ * Date Math string indicating the interval of sub-ranges for a date
+ * facet range.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_DATE_GAP = FACET_DATE + ".gap";
+ /**
+ * Boolean indicating how counts should be computed if the range
+ * between 'start' and 'end' is not evenly divisible by 'gap'. If
+ * this value is true, then all counts of ranges involving the 'end'
+ * point will use the exact endpoint specified -- this includes the
+ * 'between' and 'after' counts as well as the last range computed
+ * using the 'gap'. If the value is false, then 'gap' is used to
+ * compute the effective endpoint closest to the 'end' param which
+ * results in the range between 'start' and 'end' being evenly
+ * divisible by 'gap'.
+ * The default is false.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_DATE_HARD_END = FACET_DATE + ".hardend";
+ /**
+ * String indicating what "other" ranges should be computed for a
+ * date facet range (multi-value).
+ * Can be overriden on a per field basis.
+ * @see FacetRangeOther
+ */
+ public static final String FACET_DATE_OTHER = FACET_DATE + ".other";
+
+ /**
+ * <p>
+ * Multivalued string indicating what rules should be applied to determine
+ * when the the ranges generated for date faceting should be inclusive or
+ * exclusive of their end points.
+ * </p>
+ * <p>
+ * The default value if none are specified is: [lower,upper,edge] <i>(NOTE: This is different then FACET_RANGE_INCLUDE)</i>
+ * </p>
+ * <p>
+ * Can be overriden on a per field basis.
+ * </p>
+ * @see FacetRangeInclude
+ * @see #FACET_RANGE_INCLUDE
+ */
+ public static final String FACET_DATE_INCLUDE = FACET_DATE + ".include";
+
+ /**
+ * Any numerical field whose terms the user wants to enumerate over
+ * Facet Contraint Counts for selected ranges.
+ */
+ public static final String FACET_RANGE = FACET + ".range";
+ /**
+ * Number indicating the starting point for a numerical range facet.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_RANGE_START = FACET_RANGE + ".start";
+ /**
+ * Number indicating the ending point for a numerical range facet.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_RANGE_END = FACET_RANGE + ".end";
+ /**
+ * Number indicating the interval of sub-ranges for a numerical
+ * facet range.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_RANGE_GAP = FACET_RANGE + ".gap";
+ /**
+ * Boolean indicating how counts should be computed if the range
+ * between 'start' and 'end' is not evenly divisible by 'gap'. If
+ * this value is true, then all counts of ranges involving the 'end'
+ * point will use the exact endpoint specified -- this includes the
+ * 'between' and 'after' counts as well as the last range computed
+ * using the 'gap'. If the value is false, then 'gap' is used to
+ * compute the effective endpoint closest to the 'end' param which
+ * results in the range between 'start' and 'end' being evenly
+ * divisible by 'gap'.
+ * The default is false.
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_RANGE_HARD_END = FACET_RANGE + ".hardend";
+ /**
+ * String indicating what "other" ranges should be computed for a
+ * numerical range facet (multi-value).
+ * Can be overriden on a per field basis.
+ */
+ public static final String FACET_RANGE_OTHER = FACET_RANGE + ".other";
+
+ /**
+ * <p>
+ * Multivalued string indicating what rules should be applied to determine
+ * when the the ranges generated for numeric faceting should be inclusive or
+ * exclusive of their end points.
+ * </p>
+ * <p>
+ * The default value if none are specified is: lower
+ * </p>
+ * <p>
+ * Can be overriden on a per field basis.
+ * </p>
+ * @see FacetRangeInclude
+ */
+ public static final String FACET_RANGE_INCLUDE = FACET_RANGE + ".include";
+
+ /**
+ * Any field whose values the user wants to enumerate as explicit intervals of terms.
+ */
+ public static final String FACET_INTERVAL = FACET + ".interval";
+
+ /**
+ * Set of terms for a single interval to facet on.
+ */
+ public static final String FACET_INTERVAL_SET = FACET_INTERVAL + ".set";
+
+ /** A spatial RPT field to generate a 2D "heatmap" (grid of facet counts) on. Just like the other faceting types,
+ * this may include a 'key' or local-params to facet multiple times. All parameters with this suffix can be
+ * overridden on a per-field basis. */
+ public static final String FACET_HEATMAP = "facet.heatmap";
+
+ /** The format of the heatmap: either png or ints2D (default). */
+ public static final String FACET_HEATMAP_FORMAT = FACET_HEATMAP + ".format";
+
+ /** The region the heatmap should minimally enclose. It defaults to the world if not set. The format can either be
+ * a minimum to maximum point range format: <pre>["-150 10" TO "-100 30"]</pre> (the first is bottom-left and second
+ * is bottom-right, both of which are parsed as points are parsed). OR, any WKT can be provided and it's bounding
+ * box will be taken. */
+ public static final String FACET_HEATMAP_GEOM = FACET_HEATMAP + ".geom";
+
+ /** Specify the heatmap grid level explicitly, instead of deriving it via distErr or distErrPct. */
+ public static final String FACET_HEATMAP_LEVEL = FACET_HEATMAP + ".gridLevel";
+
+ /** Used to determine the heatmap grid level to compute, defaulting to 0.15. It has the same interpretation of
+ * distErrPct when searching on RPT, but relative to the shape in 'bbox'. It's a fraction (not a %) of the radius of
+ * the shape that grid squares must fit into without exceeding. > 0 and <= 0.5.
+ * Mutually exclusive with distErr & gridLevel. */
+ public static final String FACET_HEATMAP_DIST_ERR_PCT = FACET_HEATMAP + ".distErrPct";
+
+ /** Used to determine the heatmap grid level to compute (optional). It has the same interpretation of maxDistErr or
+ * distErr with RPT. It's an absolute distance (in units of what's specified on the field type) that a grid square
+ * must maximally fit into (width & height). It can be used to to more explicitly specify the maximum grid square
+ * size without knowledge of what particular grid levels translate to. This can in turn be used with
+ * knowledge of the size of 'bbox' to get a target minimum number of grid cells.
+ * Mutually exclusive with distErrPct & gridLevel. */
+ public static final String FACET_HEATMAP_DIST_ERR = FACET_HEATMAP + ".distErr";
+
+ /** The maximum number of cells (grid squares) the client is willing to handle. If this limit would be exceeded, we
+ * throw an error instead. Defaults to 100k. */
+ public static final String FACET_HEATMAP_MAX_CELLS = FACET_HEATMAP + ".maxCells";
+
+ /**
+ * An enumeration of the legal values for {@link #FACET_RANGE_OTHER} and {@link #FACET_DATE_OTHER} ...
+ * <ul>
+ * <li>before = the count of matches before the start</li>
+ * <li>after = the count of matches after the end</li>
+ * <li>between = the count of all matches between start and end</li>
+ * <li>all = all of the above (default value)</li>
+ * <li>none = no additional info requested</li>
+ * </ul>
+ * @see #FACET_RANGE_OTHER
+ * @see #FACET_DATE_OTHER
+ */
+ public enum FacetRangeOther {
+ BEFORE, AFTER, BETWEEN, ALL, NONE;
+ @Override
+ public String toString() { return super.toString().toLowerCase(Locale.ROOT); }
+ public static FacetRangeOther get(String label) {
+ try {
+ return valueOf(label.toUpperCase(Locale.ROOT));
+ } catch (IllegalArgumentException e) {
+ throw new SolrException
+ (SolrException.ErrorCode.BAD_REQUEST,
+ label+" is not a valid type of 'other' range facet information",e);
+ }
+ }
+ }
+
+ /**
+ * An enumeration of the legal values for {@link #FACET_DATE_INCLUDE} and {@link #FACET_RANGE_INCLUDE}
+ * <br>
+ * <ul>
+ * <li>lower = all gap based ranges include their lower bound</li>
+ * <li>upper = all gap based ranges include their upper bound</li>
+ * <li>edge = the first and last gap ranges include their edge bounds (ie: lower
+ * for the first one, upper for the last one) even if the corresponding
+ * upper/lower option is not specified
+ * </li>
+ * <li>outer = the BEFORE and AFTER ranges
+ * should be inclusive of their bounds, even if the first or last ranges
+ * already include those boundaries.
+ * </li>
+ * <li>all = shorthand for lower, upper, edge, and outer</li>
+ * </ul>
+ * @see #FACET_DATE_INCLUDE
+ * @see #FACET_RANGE_INCLUDE
+ */
+ public enum FacetRangeInclude {
+ ALL, LOWER, UPPER, EDGE, OUTER;
+ @Override
+ public String toString() { return super.toString().toLowerCase(Locale.ROOT); }
+ public static FacetRangeInclude get(String label) {
+ try {
+ return valueOf(label.toUpperCase(Locale.ROOT));
+ } catch (IllegalArgumentException e) {
+ throw new SolrException
+ (SolrException.ErrorCode.BAD_REQUEST,
+ label+" is not a valid type of for range 'include' information",e);
+ }
+ }
+ /**
+ * Convinience method for parsing the param value according to the
+ * correct semantics and applying the default of "LOWER"
+ */
+ public static EnumSet<FacetRangeInclude> parseParam(final String[] param) {
+ // short circut for default behavior
+ if (null == param || 0 == param.length )
+ return EnumSet.of(LOWER);
+
+ // build up set containing whatever is specified
+ final EnumSet<FacetRangeInclude> include
+ = EnumSet.noneOf(FacetRangeInclude.class);
+ for (final String o : param) {
+ include.add(FacetRangeInclude.get(o));
+ }
+
+ // if set contains all, then we're back to short circuting
+ if (include.contains(FacetRangeInclude.ALL))
+ return EnumSet.allOf(FacetRangeInclude.class);
+
+ // use whatever we've got.
+ return include;
+ }
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/GroupParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/GroupParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/GroupParams.java
new file mode 100644
index 0000000..ca8e2c4
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/GroupParams.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+/**
+ * Group parameters
+ */
+public interface GroupParams {
+ public static final String GROUP = "group";
+
+ public static final String GROUP_QUERY = GROUP + ".query";
+ public static final String GROUP_FIELD = GROUP + ".field";
+ public static final String GROUP_FUNC = GROUP + ".func";
+ public static final String GROUP_SORT = GROUP + ".sort";
+
+ /** the limit for the number of documents in each group */
+ public static final String GROUP_LIMIT = GROUP + ".limit";
+ /** the offset for the doclist of each group */
+ public static final String GROUP_OFFSET = GROUP + ".offset";
+
+ /** treat the first group result as the main result. true/false */
+ public static final String GROUP_MAIN = GROUP + ".main";
+
+ /** treat the first group result as the main result. true/false */
+ public static final String GROUP_FORMAT = GROUP + ".format";
+
+ /**
+ * Whether to cache the first pass search (doc ids and score) for the second pass search.
+ * Also defines the maximum size of the group cache relative to maxdoc in a percentage.
+ * Values can be a positive integer, from 0 till 100. A value of 0 will disable the group cache.
+ * The default is 0.*/
+ public static final String GROUP_CACHE_PERCENTAGE = GROUP + ".cache.percent";
+
+ // Note: Since you can supply multiple fields to group on, but only have a facets for the whole result. It only makes
+ // sense to me to support these parameters for the first group.
+ /** Whether the docSet (for example for faceting) should be based on plain documents (a.k.a UNGROUPED) or on the groups (a.k.a GROUPED).
+ * The docSet will only the most relevant documents per group. It is if you query for everything with group.limit=1 */
+ public static final String GROUP_TRUNCATE = GROUP + ".truncate";
+
+ /** Whether the group count should be included in the response. */
+ public static final String GROUP_TOTAL_COUNT = GROUP + ".ngroups";
+
+ /** Whether to compute grouped facets based on the first specified group. */
+ public static final String GROUP_FACET = GROUP + ".facet";
+
+ /** Retrieve the top search groups (top group values) from the shards being queried. */
+ public static final String GROUP_DISTRIBUTED_FIRST = GROUP + ".distributed.first";
+
+ /** Retrieve the top groups from the shards being queries based on the specified search groups in
+ * the {@link #GROUP_DISTRIBUTED_TOPGROUPS_PREFIX} parameters.
+ */
+ public static final String GROUP_DISTRIBUTED_SECOND = GROUP + ".distributed.second";
+
+ public static final String GROUP_DISTRIBUTED_TOPGROUPS_PREFIX = GROUP + ".topgroups.";
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/HighlightParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/HighlightParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/HighlightParams.java
new file mode 100644
index 0000000..ceccd74
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/HighlightParams.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+/**
+ *
+ * @since solr 1.3
+ */
+public interface HighlightParams {
+ public static final String HIGHLIGHT = "hl";
+ public static final String Q = HIGHLIGHT+".q";
+ public static final String QPARSER = HIGHLIGHT+".qparser";
+ public static final String FIELDS = HIGHLIGHT+".fl";
+ public static final String SNIPPETS = HIGHLIGHT+".snippets";
+ public static final String FRAGSIZE = HIGHLIGHT+".fragsize";
+ public static final String INCREMENT = HIGHLIGHT+".increment";
+ public static final String MAX_CHARS = HIGHLIGHT+".maxAnalyzedChars";
+ public static final String FORMATTER = HIGHLIGHT+".formatter";
+ public static final String ENCODER = HIGHLIGHT+".encoder";
+ public static final String FRAGMENTER = HIGHLIGHT+".fragmenter";
+ public static final String PRESERVE_MULTI = HIGHLIGHT+".preserveMulti";
+ public static final String FRAG_LIST_BUILDER = HIGHLIGHT+".fragListBuilder";
+ public static final String FRAGMENTS_BUILDER = HIGHLIGHT+".fragmentsBuilder";
+ public static final String BOUNDARY_SCANNER = HIGHLIGHT+".boundaryScanner";
+ public static final String BS_MAX_SCAN = HIGHLIGHT+".bs.maxScan";
+ public static final String BS_CHARS = HIGHLIGHT+".bs.chars";
+ public static final String BS_TYPE = HIGHLIGHT+".bs.type";
+ public static final String BS_LANGUAGE = HIGHLIGHT+".bs.language";
+ public static final String BS_COUNTRY = HIGHLIGHT+".bs.country";
+ public static final String BS_VARIANT = HIGHLIGHT+".bs.variant";
+ public static final String FIELD_MATCH = HIGHLIGHT+".requireFieldMatch";
+ public static final String DEFAULT_SUMMARY = HIGHLIGHT + ".defaultSummary";
+ public static final String ALTERNATE_FIELD = HIGHLIGHT+".alternateField";
+ public static final String ALTERNATE_FIELD_LENGTH = HIGHLIGHT+".maxAlternateFieldLength";
+ public static final String MAX_MULTIVALUED_TO_EXAMINE = HIGHLIGHT + ".maxMultiValuedToExamine";
+ public static final String MAX_MULTIVALUED_TO_MATCH = HIGHLIGHT + ".maxMultiValuedToMatch";
+
+ public static final String USE_PHRASE_HIGHLIGHTER = HIGHLIGHT+".usePhraseHighlighter";
+ public static final String HIGHLIGHT_MULTI_TERM = HIGHLIGHT+".highlightMultiTerm";
+ public static final String PAYLOADS = HIGHLIGHT+".payloads";
+
+ public static final String MERGE_CONTIGUOUS_FRAGMENTS = HIGHLIGHT + ".mergeContiguous";
+
+ public static final String USE_FVH = HIGHLIGHT + ".useFastVectorHighlighter";
+ public static final String TAG_PRE = HIGHLIGHT + ".tag.pre";
+ public static final String TAG_POST = HIGHLIGHT + ".tag.post";
+ public static final String TAG_ELLIPSIS = HIGHLIGHT + ".tag.ellipsis";
+ public static final String PHRASE_LIMIT = HIGHLIGHT + ".phraseLimit";
+ public static final String MULTI_VALUED_SEPARATOR = HIGHLIGHT + ".multiValuedSeparatorChar";
+
+ // Formatter
+ public static final String SIMPLE = "simple";
+ public static final String SIMPLE_PRE = HIGHLIGHT+"."+SIMPLE+".pre";
+ public static final String SIMPLE_POST = HIGHLIGHT+"."+SIMPLE+".post";
+
+ // Regex fragmenter
+ public static final String REGEX = "regex";
+ public static final String SLOP = HIGHLIGHT+"."+REGEX+".slop";
+ public static final String PATTERN = HIGHLIGHT+"."+REGEX+".pattern";
+ public static final String MAX_RE_CHARS = HIGHLIGHT+"."+REGEX+".maxAnalyzedChars";
+
+ // Scoring parameters
+ public static final String SCORE = "score";
+ public static final String SCORE_K1 = HIGHLIGHT +"."+SCORE+".k1";
+ public static final String SCORE_B = HIGHLIGHT +"."+SCORE+".b";
+ public static final String SCORE_PIVOT = HIGHLIGHT +"."+SCORE+".pivot";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/MapSolrParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/MapSolrParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/MapSolrParams.java
new file mode 100644
index 0000000..f2a1c37
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/MapSolrParams.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import org.apache.solr.common.util.StrUtils;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class MapSolrParams extends SolrParams {
+ protected final Map<String,String> map;
+
+ public MapSolrParams(Map<String,String> map) {
+ this.map = map;
+ }
+
+ @Override
+ public String get(String name) {
+ Object o = map.get(name);
+ if(o == null) return null;
+ if (o instanceof String) return (String) o;
+ if (o instanceof String[]) {
+ String[] strings = (String[]) o;
+ if(strings.length == 0) return null;
+ return strings[0];
+ }
+ return String.valueOf(o);
+ }
+
+ @Override
+ public String[] getParams(String name) {
+ Object val = map.get(name);
+ if (val instanceof String[]) return (String[]) val;
+ return val==null ? null : new String[]{String.valueOf(val)};
+ }
+
+ @Override
+ public Iterator<String> getParameterNamesIterator() {
+ return map.keySet().iterator();
+ }
+
+ public Map<String,String> getMap() { return map; }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(128);
+ try {
+ boolean first=true;
+
+ for (Map.Entry<String,String> entry : map.entrySet()) {
+ String key = entry.getKey();
+ Object val = entry.getValue();
+ if (val instanceof String[]) {
+ String[] strings = (String[]) val;
+ val = StrUtils.join(Arrays.asList(strings),',');
+ }
+ if (!first) sb.append('&');
+ first=false;
+ sb.append(key);
+ sb.append('=');
+ StrUtils.partialURLEncodeVal(sb, val==null ? "" : String.valueOf(val));
+ }
+ }
+ catch (IOException e) {throw new RuntimeException(e);} // can't happen
+
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/ModifiableSolrParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/ModifiableSolrParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/ModifiableSolrParams.java
new file mode 100644
index 0000000..b84f4aa
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/ModifiableSolrParams.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.LinkedHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * This class is similar to MultiMapSolrParams except you can edit the
+ * parameters after it is initialized. It has helper functions to set/add
+ * integer and boolean param values.
+ *
+ * @since solr 1.3
+ */
+public class ModifiableSolrParams extends SolrParams
+{
+ private Map<String,String[]> vals;
+
+ public ModifiableSolrParams()
+ {
+ // LinkedHashMap so params show up in CGI in the same order as they are entered
+ vals = new LinkedHashMap<>();
+ }
+
+ /** Constructs a new ModifiableSolrParams directly using the provided Map<String,String[]> */
+ public ModifiableSolrParams( Map<String,String[]> v )
+ {
+ vals = v;
+ }
+
+ /** Constructs a new ModifiableSolrParams, copying values from an existing SolrParams */
+ public ModifiableSolrParams(SolrParams params)
+ {
+ vals = new LinkedHashMap<>();
+ if( params != null ) {
+ this.add( params );
+ }
+ }
+
+ //----------------------------------------------------------------
+ //----------------------------------------------------------------
+
+ /**
+ * Replace any existing parameter with the given name. if val==null remove key from params completely.
+ */
+ public ModifiableSolrParams set( String name, String ... val ) {
+ if (val==null || (val.length==1 && val[0]==null)) {
+ vals.remove(name);
+ } else {
+ vals.put( name, val );
+ }
+ return this;
+ }
+
+ public ModifiableSolrParams set( String name, int val ) {
+ set( name, String.valueOf(val) );
+ return this;
+ }
+
+ public ModifiableSolrParams set( String name, boolean val ) {
+ set( name, String.valueOf(val) );
+ return this;
+ }
+
+ /**
+ * Add the given values to any existing name
+ * @param name Key
+ * @param val Array of value(s) added to the name. NOTE: If val is null
+ * or a member of val is null, then a corresponding null reference
+ * will be included when a get method is called on the key later.
+ * @return this
+ */
+ public ModifiableSolrParams add( String name, String ... val ) {
+ String[] old = vals.put(name, val);
+ if( old != null ) {
+ if( val == null || val.length < 1 ) {
+ String[] both = new String[old.length+1];
+ System.arraycopy(old, 0, both, 0, old.length);
+ both[old.length] = null;
+ vals.put( name, both );
+ }
+ else {
+ String[] both = new String[old.length+val.length];
+ System.arraycopy(old, 0, both, 0, old.length);
+ System.arraycopy(val, 0, both, old.length, val.length);
+ vals.put( name, both );
+ }
+ }
+ return this;
+ }
+
+ public void add(SolrParams params)
+ {
+ Iterator<String> names = params.getParameterNamesIterator();
+ while (names.hasNext()) {
+ String name = names.next();
+ set(name, params.getParams(name));
+ }
+ }
+
+ /**
+ * remove a field at the given name
+ */
+ public String[] remove( String name )
+ {
+ return vals.remove( name );
+ }
+
+ /** clear all parameters */
+ public void clear()
+ {
+ vals.clear();
+ }
+
+ /**
+ * remove the given value for the given name
+ *
+ * @return true if the item was removed, false if null or not present
+ */
+ public boolean remove(String name, String value) {
+ String[] tmp = vals.get(name);
+ if (tmp==null) return false;
+ for (int i=0; i<tmp.length; i++) {
+ if (tmp[i].equals(value)) {
+ String[] tmp2 = new String[tmp.length-1];
+ if (tmp2.length==0) {
+ tmp2 = null;
+ remove(name);
+ } else {
+ System.arraycopy(tmp, 0, tmp2, 0, i);
+ System.arraycopy(tmp, i+1, tmp2, i, tmp.length-i-1);
+ set(name, tmp2);
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //----------------------------------------------------------------
+ //----------------------------------------------------------------
+
+ @Override
+ public String get(String param) {
+ String[] v = vals.get( param );
+ if( v!= null && v.length > 0 ) {
+ return v[0];
+ }
+ return null;
+ }
+
+ @Override
+ public Iterator<String> getParameterNamesIterator() {
+ return vals.keySet().iterator();
+ }
+
+ public Set<String> getParameterNames() {
+ return vals.keySet();
+ }
+
+ @Override
+ public String[] getParams(String param) {
+ return vals.get( param );
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(128);
+ try {
+ boolean first=true;
+
+ for (Map.Entry<String,String[]> entry : vals.entrySet()) {
+ String key = entry.getKey();
+ String[] valarr = entry.getValue();
+ for (String val : valarr) {
+ if (!first) sb.append('&');
+ first=false;
+ sb.append(key);
+ sb.append('=');
+ if( val != null ) {
+ sb.append( URLEncoder.encode( val, "UTF-8" ) );
+ }
+ }
+ }
+ }
+ catch (IOException e) {throw new RuntimeException(e);} // can't happen
+
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/MoreLikeThisParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/MoreLikeThisParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/MoreLikeThisParams.java
new file mode 100644
index 0000000..0d808c2
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/MoreLikeThisParams.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import java.util.Locale;
+
+/**
+ * @since solr 1.3
+ */
+public interface MoreLikeThisParams
+{
+ // enable more like this -- this only applies to 'StandardRequestHandler' maybe DismaxRequestHandler
+ public final static String MLT = "mlt";
+
+ public final static String PREFIX = "mlt.";
+
+ public final static String SIMILARITY_FIELDS = PREFIX + "fl";
+ public final static String MIN_TERM_FREQ = PREFIX + "mintf";
+ public final static String MAX_DOC_FREQ = PREFIX + "maxdf";
+ public final static String MIN_DOC_FREQ = PREFIX + "mindf";
+ public final static String MIN_WORD_LEN = PREFIX + "minwl";
+ public final static String MAX_WORD_LEN = PREFIX + "maxwl";
+ public final static String MAX_QUERY_TERMS = PREFIX + "maxqt";
+ public final static String MAX_NUM_TOKENS_PARSED = PREFIX + "maxntp";
+ public final static String BOOST = PREFIX + "boost"; // boost or not?
+ public final static String QF = PREFIX + "qf"; //boosting applied to mlt fields
+
+ // the /mlt request handler uses 'rows'
+ public final static String DOC_COUNT = PREFIX + "count";
+
+ // Do you want to include the original document in the results or not
+ public final static String MATCH_INCLUDE = PREFIX + "match.include";
+
+ // If multiple docs are matched in the query, what offset do you want?
+ public final static String MATCH_OFFSET = PREFIX + "match.offset";
+
+ // Do you want to include the original document in the results or not
+ public final static String INTERESTING_TERMS = PREFIX + "interestingTerms"; // false,details,(list or true)
+
+ public enum TermStyle {
+ NONE,
+ LIST,
+ DETAILS;
+
+ public static TermStyle get( String p )
+ {
+ if( p != null ) {
+ p = p.toUpperCase(Locale.ROOT);
+ if( p.equals( "DETAILS" ) ) {
+ return DETAILS;
+ }
+ else if( p.equals( "LIST" ) ) {
+ return LIST;
+ }
+ }
+ return NONE;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/MultiMapSolrParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/MultiMapSolrParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/MultiMapSolrParams.java
new file mode 100644
index 0000000..684396b
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/MultiMapSolrParams.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import org.apache.solr.common.util.StrUtils;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class MultiMapSolrParams extends SolrParams {
+ protected final Map<String,String[]> map;
+
+ public static void addParam(String name, String val, Map<String,String[]> map) {
+ String[] arr = map.get(name);
+ if (arr ==null) {
+ arr =new String[]{val};
+ } else {
+ String[] newarr = new String[arr.length+1];
+ System.arraycopy(arr,0,newarr,0,arr.length);
+ newarr[arr.length]=val;
+ arr =newarr;
+ }
+ map.put(name, arr);
+ }
+
+ public MultiMapSolrParams(Map<String,String[]> map) {
+ this.map = map;
+ }
+
+ @Override
+ public String get(String name) {
+ String[] arr = map.get(name);
+ return arr==null ? null : arr[0];
+ }
+
+ @Override
+ public String[] getParams(String name) {
+ return map.get(name);
+ }
+
+ @Override
+ public Iterator<String> getParameterNamesIterator() {
+ return map.keySet().iterator();
+ }
+
+ public Map<String,String[]> getMap() { return map; }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(128);
+ try {
+ boolean first=true;
+
+ for (Map.Entry<String,String[]> entry : map.entrySet()) {
+ String key = entry.getKey();
+ String[] valarr = entry.getValue();
+
+ for (String val : valarr) {
+ if (!first) sb.append('&');
+ first=false;
+ sb.append(key);
+ sb.append('=');
+ StrUtils.partialURLEncodeVal(sb, val==null ? "" : val);
+ }
+ }
+ }
+ catch (IOException e) {throw new RuntimeException(e);} // can't happen
+
+ return sb.toString();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/QueryElevationParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/QueryElevationParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/QueryElevationParams.java
new file mode 100644
index 0000000..d5a0b41
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/QueryElevationParams.java
@@ -0,0 +1,53 @@
+package org.apache.solr.common.params;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Parameters used with the QueryElevationComponent
+ *
+ **/
+public interface QueryElevationParams {
+
+ String ENABLE = "enableElevation";
+ String EXCLUSIVE = "exclusive";
+ String FORCE_ELEVATION = "forceElevation";
+ String IDS = "elevateIds";
+ String EXCLUDE = "excludeIds";
+ /**
+ * The name of the field that editorial results will be written out as when using the QueryElevationComponent, which
+ * automatically configures the EditorialMarkerFactory. The default name is "elevated"
+ * <br>
+ * See http://wiki.apache.org/solr/DocTransformers
+ */
+ String EDITORIAL_MARKER_FIELD_NAME = "editorialMarkerFieldName";
+ /**
+ * The name of the field that excluded editorial results will be written out as when using the QueryElevationComponent, which
+ * automatically configures the EditorialMarkerFactory. The default name is "excluded". This is only used
+ * when {@link #MARK_EXCLUDES} is set to true at query time.
+ * <br>
+ * See http://wiki.apache.org/solr/DocTransformers
+ */
+ String EXCLUDE_MARKER_FIELD_NAME = "excludeMarkerFieldName";
+
+ /**
+ * Instead of removing excluded items from the results, passing in this parameter allows you to get back the excluded items, but to mark them
+ * as excluded.
+ */
+ String MARK_EXCLUDES = "markExcludes";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/RequiredSolrParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/RequiredSolrParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/RequiredSolrParams.java
new file mode 100644
index 0000000..0b78d41
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/RequiredSolrParams.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import org.apache.solr.common.SolrException;
+
+import java.util.Iterator;
+
+/**
+ * This is a simple wrapper to SolrParams that will throw a 400
+ * exception if you ask for a parameter that does not exist. Fields
+ * specified with
+ *
+ * In short, any value you for from a <code>RequiredSolrParams</code>
+ * will return a valid non-null value or throw a 400 exception.
+ * (If you pass in <code>null</code> as the default value, you can
+ * get a null return value)
+ *
+ *
+ * @since solr 1.2
+ */
+public class RequiredSolrParams extends SolrParams {
+ protected final SolrParams params;
+
+ public RequiredSolrParams(SolrParams params) {
+ this.params = params;
+ }
+
+ /** get the param from params, fail if not found **/
+ @Override
+ public String get(String param) {
+ String val = params.get(param);
+ if( val == null ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Missing required parameter: "+param );
+ }
+ return val;
+ }
+
+ @Override
+ public String getFieldParam(final String field, final String param) {
+ final String fpname = fpname(field,param);
+ String val = params.get(fpname);
+ if (null == val) {
+ // don't call this.get, we want a specified exception message
+ val = params.get(param);
+ if (null == val) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
+ "Missing required parameter: "+fpname+
+ " (or default: "+param+")" );
+ }
+ }
+ return val;
+ }
+
+ @Override
+ public String[] getFieldParams(final String field, final String param) {
+ final String fpname = fpname(field,param);
+ String[] val = params.getParams(fpname);
+ if (null == val) {
+ // don't call this.getParams, we want a specified exception message
+ val = params.getParams(param);
+ if (null == val) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
+ "Missing required parameter: "+fpname+
+ " (or default: "+param+")" );
+ }
+ }
+ return val;
+ }
+
+
+ @Override
+ public String[] getParams(String param) {
+ String[] vals = params.getParams(param);
+ if( vals == null || vals.length == 0 ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Missing required parameter: "+param );
+ }
+ return vals;
+ }
+
+ /** returns an Iterator over the parameter names */
+ @Override
+ public Iterator<String> getParameterNamesIterator() {
+ return params.getParameterNamesIterator();
+ }
+
+ @Override
+ public String toString() {
+ return "{required("+params+")}";
+ }
+
+ //----------------------------------------------------------
+ // Functions with a default value - pass directly to the
+ // wrapped SolrParams (they won't return null - unless it's the default)
+ //----------------------------------------------------------
+
+ @Override
+ public String get(String param, String def) {
+ return params.get(param, def);
+ }
+
+ @Override
+ public int getInt(String param, int def) {
+ return params.getInt(param, def);
+ }
+
+ @Override
+ public float getFloat(String param, float def) {
+ return params.getFloat(param, def);
+ }
+
+ @Override
+ public boolean getBool(String param, boolean def) {
+ return params.getBool(param, def);
+ }
+
+ @Override
+ public int getFieldInt(String field, String param, int def) {
+ return params.getFieldInt(field, param, def);
+ }
+
+ @Override
+ public boolean getFieldBool(String field, String param, boolean def) {
+ return params.getFieldBool(field, param, def);
+ }
+
+ @Override
+ public float getFieldFloat(String field, String param, float def) {
+ return params.getFieldFloat(field, param, def);
+ }
+
+ @Override
+ public String getFieldParam(String field, String param, String def) {
+ return params.getFieldParam(field, param, def);
+ }
+
+ public void check(String... params){
+ for (String param : params) get(param);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/ShardParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/ShardParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/ShardParams.java
new file mode 100644
index 0000000..46a9fc0
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/ShardParams.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+/**
+ * Parameters used for distributed search.
+ */
+public interface ShardParams {
+ /** the shards to use (distributed configuration) */
+ public static final String SHARDS = "shards";
+
+ /** per-shard start and rows */
+ public static final String SHARDS_ROWS = "shards.rows";
+ public static final String SHARDS_START = "shards.start";
+
+ /** IDs of the shard documents */
+ public static final String IDS = "ids";
+
+ /** whether the request goes to a shard */
+ public static final String IS_SHARD = "isShard";
+
+ /** The requested URL for this shard */
+ public static final String SHARD_URL = "shard.url";
+
+ /** The Request Handler for shard requests */
+ public static final String SHARDS_QT = "shards.qt";
+
+ /** Request detailed match info for each shard (true/false) */
+ public static final String SHARDS_INFO = "shards.info";
+
+ /** Should things fail if there is an error? (true/false) */
+ public static final String SHARDS_TOLERANT = "shards.tolerant";
+
+ /** query purpose for shard requests */
+ public static final String SHARDS_PURPOSE = "shards.purpose";
+
+ public static final String _ROUTE_ = "_route_";
+
+ /** Force a single-pass distributed query? (true/false) */
+ public static final String DISTRIB_SINGLE_PASS = "distrib.singlePass";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/SimpleParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/SimpleParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/SimpleParams.java
new file mode 100644
index 0000000..e770402
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/SimpleParams.java
@@ -0,0 +1,50 @@
+package org.apache.solr.common.params;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Parameters used by the SimpleQParser.
+ */
+public interface SimpleParams {
+ /** Query fields and boosts. */
+ public static String QF = "qf";
+
+ /** Override the currently enabled/disabled query operators. */
+ public static String QO = "q.operators";
+
+ /** Enables {@code AND} operator (+) */
+ public static final String AND_OPERATOR = "AND";
+ /** Enables {@code NOT} operator (-) */
+ public static final String NOT_OPERATOR = "NOT";
+ /** Enables {@code OR} operator (|) */
+ public static final String OR_OPERATOR = "OR";
+ /** Enables {@code PREFIX} operator (*) */
+ public static final String PREFIX_OPERATOR = "PREFIX";
+ /** Enables {@code PHRASE} operator (") */
+ public static final String PHRASE_OPERATOR = "PHRASE";
+ /** Enables {@code PRECEDENCE} operators: {@code (} and {@code )} */
+ public static final String PRECEDENCE_OPERATORS = "PRECEDENCE";
+ /** Enables {@code ESCAPE} operator (\) */
+ public static final String ESCAPE_OPERATOR = "ESCAPE";
+ /** Enables {@code WHITESPACE} operators: ' ' '\n' '\r' '\t' */
+ public static final String WHITESPACE_OPERATOR = "WHITESPACE";
+ /** Enables {@code FUZZY} operator (~) */
+ public static final String FUZZY_OPERATOR = "FUZZY";
+ /** Enables {@code NEAR} operator (~) */
+ public static final String NEAR_OPERATOR = "NEAR";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/SolrParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/SolrParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/SolrParams.java
new file mode 100644
index 0000000..36d0df1
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/SolrParams.java
@@ -0,0 +1,363 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/** SolrParams hold request parameters.
+ *
+ *
+ */
+public abstract class SolrParams implements Serializable {
+
+ /** returns the String value of a param, or null if not set */
+ public abstract String get(String param);
+
+ /** returns an array of the String values of a param, or null if none */
+ public abstract String[] getParams(String param);
+
+ /** returns an Iterator over the parameter names */
+ public abstract Iterator<String> getParameterNamesIterator();
+
+ /** returns the value of the param, or def if not set */
+ public String get(String param, String def) {
+ String val = get(param);
+ return val==null ? def : val;
+ }
+
+ /** returns a RequiredSolrParams wrapping this */
+ public RequiredSolrParams required()
+ {
+ // TODO? should we want to stash a reference?
+ return new RequiredSolrParams(this);
+ }
+
+ protected String fpname(String field, String param) {
+ return "f."+field+'.'+param;
+ }
+
+ /** returns the String value of the field parameter, "f.field.param", or
+ * the value for "param" if that is not set.
+ */
+ public String getFieldParam(String field, String param) {
+ String val = get(fpname(field,param));
+ return val!=null ? val : get(param);
+ }
+
+ /** returns the String value of the field parameter, "f.field.param", or
+ * the value for "param" if that is not set. If that is not set, def
+ */
+ public String getFieldParam(String field, String param, String def) {
+ String val = get(fpname(field,param));
+ return val!=null ? val : get(param, def);
+ }
+
+ /** returns the String values of the field parameter, "f.field.param", or
+ * the values for "param" if that is not set.
+ */
+ public String[] getFieldParams(String field, String param) {
+ String[] val = getParams(fpname(field,param));
+ return val!=null ? val : getParams(param);
+ }
+
+ /** Returns the Boolean value of the param, or null if not set */
+ public Boolean getBool(String param) {
+ String val = get(param);
+ return val==null ? null : StrUtils.parseBool(val);
+ }
+
+ /** Returns the boolean value of the param, or def if not set */
+ public boolean getBool(String param, boolean def) {
+ String val = get(param);
+ return val==null ? def : StrUtils.parseBool(val);
+ }
+
+ /** Returns the Boolean value of the field param,
+ or the value for param, or null if neither is set. */
+ public Boolean getFieldBool(String field, String param) {
+ String val = getFieldParam(field, param);
+ return val==null ? null : StrUtils.parseBool(val);
+ }
+
+ /** Returns the boolean value of the field param,
+ or the value for param, or def if neither is set. */
+ public boolean getFieldBool(String field, String param, boolean def) {
+ String val = getFieldParam(field, param);
+ return val==null ? def : StrUtils.parseBool(val);
+ }
+
+ /** Returns the Integer value of the param, or null if not set */
+ public Integer getInt(String param) {
+ String val = get(param);
+ try {
+ return val==null ? null : Integer.valueOf(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the Long value of the param, or null if not set */
+ public Long getLong(String param, Long def) {
+ String val = get(param);
+ try {
+ return val== null ? def : Long.parseLong(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the int value of the param, or def if not set */
+ public int getInt(String param, int def) {
+ String val = get(param);
+ try {
+ return val==null ? def : Integer.parseInt(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the Long value of the param, or null if not set */
+ public Long getLong(String param) {
+ String val = get(param);
+ try {
+ return val == null ? null : Long.valueOf(val);
+ } catch (Exception ex) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex);
+ }
+ }
+
+ /** Returns the long value of the param, or def if not set */
+ public long getLong(String param, long def) {
+ String val = get(param);
+ try {
+ return val == null ? def : Long.parseLong(val);
+ } catch (Exception ex) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex);
+ }
+ }
+
+
+ /**
+ * @return The int value of the field param, or the value for param
+ * or <code>null</code> if neither is set.
+ **/
+ public Integer getFieldInt(String field, String param) {
+ String val = getFieldParam(field, param);
+ try {
+ return val==null ? null : Integer.valueOf(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the int value of the field param,
+ or the value for param, or def if neither is set. */
+ public int getFieldInt(String field, String param, int def) {
+ String val = getFieldParam(field, param);
+ try {
+ return val==null ? def : Integer.parseInt(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+
+ /** Returns the Float value of the param, or null if not set */
+ public Float getFloat(String param) {
+ String val = get(param);
+ try {
+ return val==null ? null : Float.valueOf(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the float value of the param, or def if not set */
+ public float getFloat(String param, float def) {
+ String val = get(param);
+ try {
+ return val==null ? def : Float.parseFloat(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the Float value of the param, or null if not set */
+ public Double getDouble(String param) {
+ String val = get(param);
+ try {
+ return val==null ? null : Double.valueOf(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the float value of the param, or def if not set */
+ public double getDouble(String param, double def) {
+ String val = get(param);
+ try {
+ return val==null ? def : Double.parseDouble(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+
+ /** Returns the float value of the field param. */
+ public Float getFieldFloat(String field, String param) {
+ String val = getFieldParam(field, param);
+ try {
+ return val==null ? null : Float.valueOf(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the float value of the field param,
+ or the value for param, or def if neither is set. */
+ public float getFieldFloat(String field, String param, float def) {
+ String val = getFieldParam(field, param);
+ try {
+ return val==null ? def : Float.parseFloat(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the float value of the field param. */
+ public Double getFieldDouble(String field, String param) {
+ String val = getFieldParam(field, param);
+ try {
+ return val==null ? null : Double.valueOf(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ /** Returns the float value of the field param,
+ or the value for param, or def if neither is set. */
+ public double getFieldDouble(String field, String param, double def) {
+ String val = getFieldParam(field, param);
+ try {
+ return val==null ? def : Double.parseDouble(val);
+ }
+ catch( Exception ex ) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, ex.getMessage(), ex );
+ }
+ }
+
+ public static SolrParams wrapDefaults(SolrParams params, SolrParams defaults) {
+ if (params == null)
+ return defaults;
+ if (defaults == null)
+ return params;
+ return new DefaultSolrParams(params,defaults);
+ }
+
+ public static SolrParams wrapAppended(SolrParams params, SolrParams defaults) {
+ if (params == null)
+ return defaults;
+ if (defaults == null)
+ return params;
+ return AppendedSolrParams.wrapAppended(params,defaults);
+ }
+
+ /** Create a Map<String,String> from a NamedList given no keys are repeated */
+ public static Map<String,String> toMap(NamedList params) {
+ HashMap<String,String> map = new HashMap<>();
+ for (int i=0; i<params.size(); i++) {
+ map.put(params.getName(i), params.getVal(i).toString());
+ }
+ return map;
+ }
+
+ /** Create a Map<String,String[]> from a NamedList */
+ public static Map<String,String[]> toMultiMap(NamedList params) {
+ HashMap<String,String[]> map = new HashMap<>();
+ for (int i=0; i<params.size(); i++) {
+ String name = params.getName(i);
+ String val = params.getVal(i).toString();
+ MultiMapSolrParams.addParam(name,val,map);
+ }
+ return map;
+ }
+
+ /** Create SolrParams from NamedList. */
+ public static SolrParams toSolrParams(NamedList params) {
+ // if no keys are repeated use the faster MapSolrParams
+ HashMap<String,String> map = new HashMap<>();
+ for (int i=0; i<params.size(); i++) {
+ String prev = map.put(params.getName(i), params.getVal(i).toString());
+ if (prev!=null) return new MultiMapSolrParams(toMultiMap(params));
+ }
+ return new MapSolrParams(map);
+ }
+
+ /** Create filtered SolrParams. */
+ public SolrParams toFilteredSolrParams(List<String> names) {
+ NamedList<String> nl = new NamedList<>();
+ for (Iterator<String> it = getParameterNamesIterator(); it.hasNext();) {
+ final String name = it.next();
+ if (names.contains(name)) {
+ final String[] values = getParams(name);
+ for (String value : values) {
+ nl.add(name, value);
+ }
+ }
+ }
+ return toSolrParams(nl);
+ }
+
+ /** Convert this to a NamedList */
+ public NamedList<Object> toNamedList() {
+ final SimpleOrderedMap<Object> result = new SimpleOrderedMap<>();
+
+ for(Iterator<String> it=getParameterNamesIterator(); it.hasNext(); ) {
+ final String name = it.next();
+ final String [] values = getParams(name);
+ if(values.length==1) {
+ result.add(name,values[0]);
+ } else {
+ // currently no reason not to use the same array
+ result.add(name,values);
+ }
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/SpatialParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/SpatialParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/SpatialParams.java
new file mode 100644
index 0000000..043f216
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/SpatialParams.java
@@ -0,0 +1,41 @@
+package org.apache.solr.common.params;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ *
+ *
+ **/
+public interface SpatialParams {
+ public static final String POINT = "pt";
+ public static final String DISTANCE = "d";
+ public static final String FIELD = "sfield"; // the field that contains the points we are measuring from "pt"
+ /**
+ * km - kilometers
+ * mi - miles
+ */
+ public static final String UNITS = "units";
+ /**
+ * The distance measure to use.
+ */
+ public static final String MEASURE = "meas";
+ /**
+ * The radius of the sphere to use to in calculating spherical distances like Haversine
+ */
+ public static final String SPHERE_RADIUS = "sphere_radius";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/SpellingParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/SpellingParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/SpellingParams.java
new file mode 100644
index 0000000..918592d
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/SpellingParams.java
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+/**
+ * Parameters used for spellchecking
+ *
+ * @since solr 1.3
+ */
+public interface SpellingParams {
+
+ public static final String SPELLCHECK_PREFIX = "spellcheck.";
+
+ /**
+ * The name of the dictionary to be used for giving the suggestion for a
+ * request. The value for this parameter is configured in solrconfig.xml
+ */
+ public static final String SPELLCHECK_DICT = SPELLCHECK_PREFIX + "dictionary";
+
+ /**
+ * The count of suggestions to return for each query term not in the index and/or dictionary.
+ * <p>
+ * If this parameter is absent in the request then only one suggestion is
+ * returned. If it is more than one then a maximum of given suggestions are
+ * returned for each token in the query.
+ */
+ public static final String SPELLCHECK_COUNT = SPELLCHECK_PREFIX + "count";
+
+ /**
+ * The count of suggestions to return for each query term existing in the index and/or dictionary.
+ * <p>
+ * If this parameter is absent in the request then no suggestions are generated. This parameter allows
+ * for receiving alternative terms to use in context-sensitive spelling corrections.
+ */
+ public static final String SPELLCHECK_ALTERNATIVE_TERM_COUNT = SPELLCHECK_PREFIX + "alternativeTermCount";
+
+ /**
+ * <p>
+ * The maximum number of hits the request can return in order to both
+ * generate spelling suggestions and set the "correctlySpelled" element to "false".
+ * Note that this parameter is typically of use only in conjunction with "spellcheck.alternativeTermCount".
+ * </p>
+ * <p>
+ * If left unspecified, the default behavior will prevail. That is, "correctlySpelled" will be false and suggestions
+ * will be returned only if one or more of the query terms are absent from the dictionary and/or index. If set to zero,
+ * the "correctlySpelled" flag will be false only if the response returns zero hits. If set to a value greater than zero,
+ * suggestions will be returned even if hits are returned (up to the specified number). This number also will serve as
+ * the threshold in determining the value of "correctlySpelled". Specifying a value greater than zero is useful
+ * for creating "did-you-mean" suggestions for queries that return a low number of hits.
+ * </p>
+ */
+ public static final String SPELLCHECK_MAX_RESULTS_FOR_SUGGEST = SPELLCHECK_PREFIX + "maxResultsForSuggest";
+
+ /**
+ * When this parameter is set to true and the misspelled word exists in the
+ * user field, only words that occur more frequently in the Solr field than
+ * the one given will be returned. The default value is false.
+ * <p>
+ * <b>This is applicable only for dictionaries built from Solr fields.</b>
+ */
+ public static final String SPELLCHECK_ONLY_MORE_POPULAR = SPELLCHECK_PREFIX + "onlyMorePopular";
+
+ /**
+ * Whether to use the extended response format, which is more complicated but
+ * richer. Returns the document frequency for each suggestion and returns one
+ * suggestion block for each term in the query string. Default is false.
+ * <p>
+ * <b>This is applicable only for dictionaries built from Solr fields.</b>
+ */
+ public static final String SPELLCHECK_EXTENDED_RESULTS = SPELLCHECK_PREFIX + "extendedResults";
+
+ /**
+ * Use the value for this parameter as the query to spell check.
+ * <p>
+ * This parameter is <b>optional</b>. If absent, then the q parameter is
+ * used.
+ */
+ public static final String SPELLCHECK_Q = SPELLCHECK_PREFIX + "q";
+
+ /**
+ * Whether to build the index or not. Optional and false by default.
+ */
+ public static final String SPELLCHECK_BUILD = SPELLCHECK_PREFIX + "build";
+
+ /**
+ * Whether to reload the index. Optional and false by default.
+ */
+ public static final String SPELLCHECK_RELOAD = SPELLCHECK_PREFIX + "reload";
+
+ /**
+ * Take the top suggestion for each token and create a new query from it
+ */
+ public static final String SPELLCHECK_COLLATE = SPELLCHECK_PREFIX + "collate";
+ /**
+ * <p>
+ * The maximum number of collations to return. Default=1. Ignored if "spellcheck.collate" is false.
+ * </p>
+ */
+ public static final String SPELLCHECK_MAX_COLLATIONS = SPELLCHECK_PREFIX + "maxCollations";
+ /**
+ * <p>
+ * The maximum number of collations to test by querying against the index.
+ * When testing, the collation is substituted for the original query's "q" param. Any "qf"s are retained.
+ * If this is set to zero, does not test for hits before returning collations (returned collations may result in zero hits).
+ * Default=0. Ignored of "spellcheck.collate" is false.
+ * </p>
+ */
+ public static final String SPELLCHECK_MAX_COLLATION_TRIES = SPELLCHECK_PREFIX + "maxCollationTries";
+ /**
+ * <p>
+ * The maximum number of word correction combinations to rank and evaluate prior to deciding which collation
+ * candidates to test against the index. This is a performance safety-net in cases a user enters a query with
+ * many misspelled words. The default is 10,000 combinations.
+ * </p>
+ */
+ public static final String SPELLCHECK_MAX_COLLATION_EVALUATIONS = SPELLCHECK_PREFIX + "maxCollationEvaluations";
+ /**
+ * <p>
+ * For use with {@link SpellingParams#SPELLCHECK_MAX_COLLATION_TRIES} and
+ * {@link SpellingParams#SPELLCHECK_COLLATE_EXTENDED_RESULTS}.
+ * A performance optimization in cases where the exact number of hits a collation would return is not needed.
+ * Specify "0" to return the exact # of hits, otherwise give the maximum documents Lucene should collect
+ * with which to base an estimate. The higher the value the more likely the estimates will be accurate
+ * (at expense of performance).
+ * </p>
+ *
+ * <p>
+ * The default is 0 (report exact hit-counts) when {@link SpellingParams#SPELLCHECK_COLLATE_EXTENDED_RESULTS} is TRUE.
+ * When {@link SpellingParams#SPELLCHECK_COLLATE_EXTENDED_RESULTS} is FALSE, this optimization is always performed.
+ * </p>
+ */
+ public static final String SPELLCHECK_COLLATE_MAX_COLLECT_DOCS = SPELLCHECK_PREFIX + "collateMaxCollectDocs";
+ /**
+ * <p>
+ * Whether to use the Extended Results Format for collations.
+ * Includes "before>after" pairs to easily allow clients to generate messages like "no results for PORK. did you mean POLK?"
+ * Also indicates the # of hits each collation will return on re-query. Default=false, which retains 1.4-compatible output.
+ * </p>
+ * <p>
+ * Note: that if {@link SpellingParams#SPELLCHECK_COLLATE_MAX_COLLECT_DOCS} is set to a value greater than 0,
+ * then the hit counts returned by this will be estimated.
+ * </p>
+ */
+ public static final String SPELLCHECK_COLLATE_EXTENDED_RESULTS = SPELLCHECK_PREFIX + "collateExtendedResults";
+
+ /**
+ * <p>
+ * For use with {@link SpellingParams#SPELLCHECK_MAX_COLLATION_TRIES}, use this to override any original query parameters
+ * when issuing test queries. For instance, if the original query has "mm=1" but it is preferred to test collations
+ * with "mm=100%", then use "spellcheck.collateParam.mm=100%".
+ * </p>
+ */
+ public static final String SPELLCHECK_COLLATE_PARAM_OVERRIDE = SPELLCHECK_PREFIX + "collateParam.";
+ /**
+ * Certain spelling implementations may allow for an accuracy setting.
+ */
+ public static final String SPELLCHECK_ACCURACY = SPELLCHECK_PREFIX + "accuracy";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/StatsParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/StatsParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/StatsParams.java
new file mode 100644
index 0000000..6fb7935
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/StatsParams.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+/**
+ * Stats Parameters
+ */
+public interface StatsParams {
+ public static final String STATS = "stats";
+ public static final String STATS_FIELD = STATS + ".field";
+ public static final String STATS_FACET = STATS + ".facet";
+ public static final String STATS_CALC_DISTINCT = STATS + ".calcdistinct";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/TermVectorParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/TermVectorParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/TermVectorParams.java
new file mode 100644
index 0000000..cfa1afd
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/TermVectorParams.java
@@ -0,0 +1,66 @@
+package org.apache.solr.common.params;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ *
+ *
+ **/
+public interface TermVectorParams {
+
+ public static final String TV_PREFIX = "tv.";
+
+ /**
+ * Return Term Frequency info
+ * */
+ public static final String TF = TV_PREFIX + "tf";
+ /**
+ * Return Term Vector position information
+ *
+ * */
+ public static final String POSITIONS = TV_PREFIX + "positions";
+ /**
+ * Return offset information, if available
+ * */
+ public static final String OFFSETS = TV_PREFIX + "offsets";
+ /**
+ * Return IDF information. May be expensive
+ * */
+ public static final String DF = TV_PREFIX + "df";
+
+ /**
+ * Return TF-IDF calculation, i.e. (tf / idf). May be expensive.
+ */
+ public static final String TF_IDF = TV_PREFIX + "tf_idf";
+
+
+ /**
+ * Return all the options: TF, positions, offsets, idf
+ */
+ public static final String ALL = TV_PREFIX + "all";
+
+ /**
+ * The fields to get term vectors for
+ */
+ public static final String FIELDS = TV_PREFIX + "fl";
+
+ /**
+ * The Doc Ids (Lucene internal ids) of the docs to get the term vectors for
+ */
+ public static final String DOC_IDS = TV_PREFIX + "docIds";
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/40aa090d/ranger_solrj/src/main/java/org/apache/solr/common/params/TermsParams.java
----------------------------------------------------------------------
diff --git a/ranger_solrj/src/main/java/org/apache/solr/common/params/TermsParams.java b/ranger_solrj/src/main/java/org/apache/solr/common/params/TermsParams.java
new file mode 100644
index 0000000..9558efc
--- /dev/null
+++ b/ranger_solrj/src/main/java/org/apache/solr/common/params/TermsParams.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.common.params;
+
+import java.util.regex.Pattern;
+
+/**
+ *
+ *
+ **/
+public interface TermsParams {
+ /**
+ * The component name. Set to true to turn on the TermsComponent
+ */
+ public static final String TERMS = "terms";
+
+ /**
+ * Used for building up the other terms
+ */
+ public static final String TERMS_PREFIX = TERMS + ".";
+
+ /**
+ * Required. Specify the field to look up terms in.
+ */
+ public static final String TERMS_FIELD = TERMS_PREFIX + "fl";
+
+ /**
+ * Optional. The lower bound term to start at. The TermEnum will start at the next term after this term in the dictionary.
+ *
+ * If not specified, the empty string is used
+ */
+ public static final String TERMS_LOWER = TERMS_PREFIX + "lower";
+
+ /**
+ * Optional. The term to stop at.
+ *
+ * @see #TERMS_UPPER_INCLUSIVE
+ */
+ public static final String TERMS_UPPER = TERMS_PREFIX + "upper";
+ /**
+ * Optional. If true, include the upper bound term in the results. False by default.
+ */
+ public static final String TERMS_UPPER_INCLUSIVE = TERMS_PREFIX + "upper.incl";
+
+ /**
+ * Optional. If true, include the lower bound term in the results, otherwise skip to the next one. True by default.
+ */
+ public static final String TERMS_LOWER_INCLUSIVE = TERMS_PREFIX + "lower.incl";
+
+ /**
+ * Optional. The number of results to return. If not specified, looks for {@link org.apache.solr.common.params.CommonParams#ROWS}. If that's not specified, uses 10.
+ */
+ public static final String TERMS_LIMIT = TERMS_PREFIX + "limit";
+
+ public static final String TERMS_PREFIX_STR = TERMS_PREFIX + "prefix";
+
+ public static final String TERMS_REGEXP_STR = TERMS_PREFIX + "regex";
+
+ public static final String TERMS_REGEXP_FLAG = TERMS_REGEXP_STR + ".flag";
+
+ public static enum TermsRegexpFlag {
+ UNIX_LINES(Pattern.UNIX_LINES),
+ CASE_INSENSITIVE(Pattern.CASE_INSENSITIVE),
+ COMMENTS(Pattern.COMMENTS),
+ MULTILINE(Pattern.MULTILINE),
+ LITERAL(Pattern.LITERAL),
+ DOTALL(Pattern.DOTALL),
+ UNICODE_CASE(Pattern.UNICODE_CASE),
+ CANON_EQ(Pattern.CANON_EQ);
+
+ int value;
+
+ TermsRegexpFlag(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+ }
+
+ /**
+ * Optional. The minimum value of docFreq to be returned. 1 by default
+ */
+ public static final String TERMS_MINCOUNT = TERMS_PREFIX + "mincount";
+ /**
+ * Optional. The maximum value of docFreq to be returned. -1 by default means no boundary
+ */
+ public static final String TERMS_MAXCOUNT = TERMS_PREFIX + "maxcount";
+
+ /**
+ * Optional. If true, return the raw characters of the indexed term, regardless of if it is readable.
+ * For instance, the index form of numeric numbers is not human readable. The default is false.
+ */
+ public static final String TERMS_RAW = TERMS_PREFIX + "raw";
+
+ /**
+ * Optional. If sorting by frequency is enabled. Defaults to sorting by count.
+ */
+ public static final String TERMS_SORT = TERMS_PREFIX + "sort";
+
+ public static final String TERMS_SORT_COUNT = "count";
+ public static final String TERMS_SORT_INDEX = "index";
+}
+