http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/AnalysisResponseBase.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/AnalysisResponseBase.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/AnalysisResponseBase.java deleted file mode 100644 index 21396a5..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/AnalysisResponseBase.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.common.util.NamedList; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * A base class for all analysis responses. - * - * - * @since solr 1.4 - */ -public class AnalysisResponseBase extends SolrResponseBase { - - /** - * Parses the given named list and builds a list of analysis phases form it. Expects a named list of the form: - * <br> - * <pre><code> - * <lst name="index"> - * <arr name="Tokenizer"> - * <str name="text">the_text</str> - * <str name="rawText">the_raw_text</str> (optional) - * <str name="type">the_type</str> - * <int name="start">1</str> - * <int name="end">3</str> - * <int name="position">1</str> - * <bool name="match">true | false</bool> (optional) - * </arr> - * <arr name="Filter1"> - * <str name="text">the_text</str> - * <str name="rawText">the_raw_text</str> (optional) - * <str name="type">the_type</str> - * <int name="start">1</str> - * <int name="end">3</str> - * <int name="position">1</str> - * <bool name="match">true | false</bool> (optional) - * </arr> - * ... - * </lst> - * </code></pre> - * - * @param phaseNL The names list to parse. - * - * @return The built analysis phases list. - */ - protected List<AnalysisPhase> buildPhases(NamedList<List<NamedList<Object>>> phaseNL) { - List<AnalysisPhase> phases = new ArrayList<>(phaseNL.size()); - for (Map.Entry<String, List<NamedList<Object>>> phaseEntry : phaseNL) { - AnalysisPhase phase = new AnalysisPhase(phaseEntry.getKey()); - List<NamedList<Object>> tokens = phaseEntry.getValue(); - for (NamedList<Object> token : tokens) { - TokenInfo tokenInfo = buildTokenInfo(token); - phase.addTokenInfo(tokenInfo); - } - phases.add(phase); - } - return phases; - } - - /** - * Parses the given named list and builds a token infoform it. Expects a named list of the form: - * <br> - * <pre><code> - * <arr name="Tokenizer"> - * <str name="text">the_text</str> - * <str name="rawText">the_raw_text</str> (optional) - * <str name="type">the_type</str> - * <int name="start">1</str> - * <int name="end">3</str> - * <int name="position">1</str> - * <bool name="match">true | false</bool> (optional) - * </arr> - * </code></pre> - * - * @param tokenNL The named list to parse. - * - * @return The built token info. - */ - protected TokenInfo buildTokenInfo(NamedList<Object> tokenNL) { - String text = (String) tokenNL.get("text"); - String rawText = (String) tokenNL.get("rawText"); - String type = (String) tokenNL.get("type"); - int start = (Integer) tokenNL.get("start"); - int end = (Integer) tokenNL.get("end"); - int position = (Integer) tokenNL.get("position"); - Boolean match = (Boolean) tokenNL.get("match"); - return new TokenInfo(text, rawText, type, start, end, position, (match == null ? false : match)); - } - - - //================================================= Inner Classes ================================================== - - /** - * A phase in the analysis process. The phase holds the tokens produced in this phase and the name of the class that - * produced them. - */ - public static class AnalysisPhase { - - private final String className; - private List<TokenInfo> tokens = new ArrayList<>(); - - AnalysisPhase(String className) { - this.className = className; - } - - /** - * The name of the class (analyzer, tokenzier, or filter) that produced the token stream for this phase. - * - * @return The name of the class that produced the token stream for this phase. - */ - public String getClassName() { - return className; - } - - private void addTokenInfo(TokenInfo tokenInfo) { - tokens.add(tokenInfo); - } - - /** - * Returns a list of tokens which represent the token stream produced in this phase. - * - * @return A list of tokens which represent the token stream produced in this phase. - */ - public List<TokenInfo> getTokens() { - return tokens; - } - - } - - /** - * Holds all information of a token as part of an analysis phase. - */ - public static class TokenInfo { - - private final String text; - private final String rawText; - private final String type; - private final int start; - private final int end; - private final int position; - private final boolean match; - - /** - * Constructs a new TokenInfo. - * - * @param text The text of the token - * @param rawText The raw text of the token. If the token is stored in the index in a special format (e.g. - * dates or padded numbers) this argument should hold this value. If the token is stored as is, - * then this value should be {@code null}. - * @param type The type fo the token (typically either {@code word} or {@code <ALPHANUM>} though it depends - * on the tokenizer/filter used). - * @param start The start position of the token in the original text where it was extracted from. - * @param end The end position of the token in the original text where it was extracted from. - * @param position The position of the token within the token stream. - * @param match Indicates whether this token matches one of the the query tokens. - */ - TokenInfo(String text, String rawText, String type, int start, int end, int position, boolean match) { - this.text = text; - this.rawText = rawText; - this.type = type; - this.start = start; - this.end = end; - this.position = position; - this.match = match; - } - - /** - * Returns the text of the token. - * - * @return The text of the token. - */ - public String getText() { - return text; - } - - /** - * Returns the raw text of the token. If the token is index in a special format (e.g. date or paddded numbers) - * it will be returned as the raw text. Returns {@code null} if the token is indexed as is. - * - * @return Returns the raw text of the token. - */ - public String getRawText() { - return rawText; - } - - /** - * Returns the type of the token. Typically this will be {@code word} or {@code <ALPHANUM>}, but it really - * depends on the tokenizer and filters that are used. - * - * @return The type of the token. - */ - public String getType() { - return type; - } - - /** - * Returns the start position of this token within the text it was originally extracted from. - * - * @return The start position of this token within the text it was originally extracted from. - */ - public int getStart() { - return start; - } - - /** - * Returns the end position of this token within the text it was originally extracted from. - * - * @return The end position of this token within the text it was originally extracted from. - */ - public int getEnd() { - return end; - } - - /** - * Returns the position of this token within the produced token stream. - * - * @return The position of this token within the produced token stream. - */ - public int getPosition() { - return position; - } - - /** - * Returns whether this token matches one of the query tokens (if query analysis is performed). - * - * @return Whether this token matches one of the query tokens (if query analysis is performed). - */ - public boolean isMatch() { - return match; - } - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java deleted file mode 100644 index 8acf2e2..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CollectionAdminResponse.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.solr.common.util.NamedList; - -public class CollectionAdminResponse extends SolrResponseBase -{ - @SuppressWarnings("unchecked") - public NamedList<NamedList<Object>> getCollectionStatus() - { - return (NamedList<NamedList<Object>>) getResponse().get( "success" ); - } - - public boolean isSuccess() - { - return getResponse().get( "success" ) != null; - } - - // this messages are typically from individual nodes, since - // all the failures at the router are propagated as exceptions - @SuppressWarnings("unchecked") - public NamedList<String> getErrorMessages() - { - return (NamedList<String>) getResponse().get( "failure" ); - } - - @SuppressWarnings("unchecked") - public Map<String, NamedList<Integer>> getCollectionCoresStatus() - { - Map<String, NamedList<Integer>> res = new HashMap<>(); - NamedList<NamedList<Object>> cols = getCollectionStatus(); - if( cols != null ) { - for (Map.Entry<String, NamedList<Object>> e : cols) { - NamedList<Object> item = e.getValue(); - String core = (String) item.get("core"); - if (core != null) { - res.put(core, (NamedList<Integer>)item.get("responseHeader")); - } - } - } - - return res; - } - - @SuppressWarnings("unchecked") - public Map<String, NamedList<Integer>> getCollectionNodesStatus() - { - Map<String, NamedList<Integer>> res = new HashMap<>(); - NamedList<NamedList<Object>> cols = getCollectionStatus(); - if( cols != null ) { - for (Map.Entry<String,NamedList<Object>> e : cols) { - if (e.getKey() != null) { - res.put(e.getKey(), (NamedList<Integer>) (e.getValue().get("responseHeader"))); - } - } - } - - return res; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CoreAdminResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CoreAdminResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CoreAdminResponse.java deleted file mode 100644 index 0492165..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/CoreAdminResponse.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.util.Date; -import org.apache.solr.common.util.NamedList; - -/** - * - * - * @since solr 1.3 - */ -public class CoreAdminResponse extends SolrResponseBase -{ - @SuppressWarnings("unchecked") - public NamedList<NamedList<Object>> getCoreStatus() - { - return (NamedList<NamedList<Object>>) getResponse().get( "status" ); - } - - public NamedList<Object> getCoreStatus( String core ) - { - return getCoreStatus().get( core ); - } - - public Date getStartTime( String core ) - { - NamedList<Object> v = getCoreStatus( core ); - if( v == null ) { - return null; - } - return (Date) v.get( "startTime" ); - } - - public Long getUptime( String core ) - { - NamedList<Object> v = getCoreStatus( core ); - if( v == null ) { - return null; - } - return (Long) v.get( "uptime" ); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java deleted file mode 100644 index 2f11d78..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/DocumentAnalysisResponse.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.common.util.NamedList; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * A response that is returned by processing the {@link org.apache.solr.client.solrj.request.DocumentAnalysisRequest}. - * Holds a map of {@link DocumentAnalysis} objects by a document id (unique key). - * - * - * @since solr 1.4 - */ -public class DocumentAnalysisResponse extends AnalysisResponseBase implements Iterable<Map.Entry<String, DocumentAnalysisResponse.DocumentAnalysis>> { - - private final Map<String, DocumentAnalysis> documentAnalysisByKey = new HashMap<>(); - - /** - * {@inheritDoc} - */ - @Override - public void setResponse(NamedList<Object> response) { - super.setResponse(response); - - @SuppressWarnings("unchecked") - NamedList<NamedList<NamedList<Object>>> analysis - = (NamedList<NamedList<NamedList<Object>>>) response.get("analysis"); - for (Map.Entry<String, NamedList<NamedList<Object>>> document : analysis) { - DocumentAnalysis documentAnalysis = new DocumentAnalysis(document.getKey()); - for (Map.Entry<String, NamedList<Object>> fieldEntry : document.getValue()) { - FieldAnalysis fieldAnalysis = new FieldAnalysis(fieldEntry.getKey()); - - NamedList<Object> field = fieldEntry.getValue(); - - @SuppressWarnings("unchecked") - NamedList<List<NamedList<Object>>> query - = (NamedList<List<NamedList<Object>>>) field.get("query"); - if (query != null) { - List<AnalysisPhase> phases = buildPhases(query); - fieldAnalysis.setQueryPhases(phases); - } - - @SuppressWarnings("unchecked") - NamedList<NamedList<List<NamedList<Object>>>> index - = (NamedList<NamedList<List<NamedList<Object>>>>) field.get("index"); - for (Map.Entry<String, NamedList<List<NamedList<Object>>>> valueEntry : index) { - String fieldValue = valueEntry.getKey(); - NamedList<List<NamedList<Object>>> valueNL = valueEntry.getValue(); - List<AnalysisPhase> phases = buildPhases(valueNL); - fieldAnalysis.setIndexPhases(fieldValue, phases); - } - - documentAnalysis.addFieldAnalysis(fieldAnalysis); - } - - documentAnalysisByKey.put(documentAnalysis.getDocumentKey(), documentAnalysis); - } - } - - /** - * Returns the number of document analyses in this response. - * - * @return The number of document analyses in this response. - */ - public int getDocumentAnalysesCount() { - return documentAnalysisByKey.size(); - } - - /** - * Returns the document analysis for the document associated with the given unique key (id), {@code null} if no such - * association exists. - * - * @param documentKey The document unique key. - * - * @return The document analysis for the document associated with the given unique key (id). - */ - public DocumentAnalysis getDocumentAnalysis(String documentKey) { - return documentAnalysisByKey.get(documentKey); - } - - /** - * Returns an iterator over the document analyses map. - * - * @return An iterator over the document analyses map. - */ - @Override - public Iterator<Map.Entry<String, DocumentAnalysis>> iterator() { - return documentAnalysisByKey.entrySet().iterator(); - } - - //================================================= Inner Classes ================================================== - - /** - * An analysis process breakdown of a document. Holds a map of field analyses by the field name. - */ - public static class DocumentAnalysis implements Iterable<Map.Entry<String, FieldAnalysis>> { - - private final String documentKey; - private Map<String, FieldAnalysis> fieldAnalysisByFieldName = new HashMap<>(); - - private DocumentAnalysis(String documentKey) { - this.documentKey = documentKey; - } - - private void addFieldAnalysis(FieldAnalysis fieldAnalysis) { - fieldAnalysisByFieldName.put(fieldAnalysis.getFieldName(), fieldAnalysis); - } - - /** - * Returns the unique key of the analyzed document. - * - * @return The unique key of the analyzed document. - */ - public String getDocumentKey() { - return documentKey; - } - - /** - * Returns the number of field analyses for the documents. - * - * @return The number of field analyses for the documents. - */ - public int getFieldAnalysesCount() { - return fieldAnalysisByFieldName.size(); - } - - public FieldAnalysis getFieldAnalysis(String fieldName) { - return fieldAnalysisByFieldName.get(fieldName); - } - - /** - * Returns an iterator over the field analyses map. - * - * @return An iterator over the field analyses map. - */ - @Override - public Iterator<Map.Entry<String, FieldAnalysis>> iterator() { - return fieldAnalysisByFieldName.entrySet().iterator(); - } - } - - /** - * An analysis process breakdown for a specific field. Holds a list of query time analysis phases (that is, if a - * query analysis was requested in the first place) and a list of index time analysis phases for each field value (a - * field can be multi-valued). - */ - public static class FieldAnalysis { - - private final String fieldName; - private List<AnalysisPhase> queryPhases; - private Map<String, List<AnalysisPhase>> indexPhasesByFieldValue = new HashMap<>(); - - private FieldAnalysis(String fieldName) { - this.fieldName = fieldName; - } - - public void setQueryPhases(List<AnalysisPhase> queryPhases) { - this.queryPhases = queryPhases; - } - - public void setIndexPhases(String fieldValue, List<AnalysisPhase> indexPhases) { - indexPhasesByFieldValue.put(fieldValue, indexPhases); - } - - /** - * Returns the field name. - * - * @return The name of the field. - */ - public String getFieldName() { - return fieldName; - } - - /** - * Returns the number of query time analysis phases or {@code -1} if - * this field analysis doesn't hold a query time analysis. - * - * @return Returns the number of query time analysis phases or {@code -1} - * if this field analysis doesn't hold a query time analysis. - */ - public int getQueryPhasesCount() { - return queryPhases == null ? -1 : queryPhases.size(); - } - - /** - * Returns the query time analysis phases for the field or {@code null} - * if this field doesn't hold a query time analysis. - * - * @return Returns the query time analysis phases for the field or - * {@code null} if this field doesn't hold a query time analysis. - */ - public Iterable<AnalysisPhase> getQueryPhases() { - return queryPhases; - } - - /** - * Returns the number of values the field has. - * - * @return The number of values the field has. - */ - public int getValueCount() { - return indexPhasesByFieldValue.entrySet().size(); - } - - /** - * Returns the number of index time analysis phases the given field value has. - * - * @param fieldValue The field value. - * - * @return The number of index time analysis phases the given field value has. - */ - public int getIndexPhasesCount(String fieldValue) { - return indexPhasesByFieldValue.get(fieldValue).size(); - } - - /** - * Returns the index time analysis phases for the given field value. - * - * @param fieldValue The field value. - * - * @return The index time analysis phases for the given field value. - */ - public Iterable<AnalysisPhase> getIndexPhases(String fieldValue) { - return indexPhasesByFieldValue.get(fieldValue); - } - - /** - * Returns the index time analysis phases for all field values. - * - * @return Returns the index time analysis phases for all field value. - */ - public Iterable<Map.Entry<String, List<AnalysisPhase>>> getIndexPhasesByFieldValue() { - return indexPhasesByFieldValue.entrySet(); - } - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FacetField.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FacetField.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FacetField.java deleted file mode 100644 index 086c999..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FacetField.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.apache.solr.client.solrj.util.ClientUtils; - - /** - * A utility class to hold the facet response. It could use the NamedList container, - * but for JSTL, it is nice to have something that implements List so it can be iterated - * - * @since solr 1.3 - */ - public class FacetField implements Serializable - { - public static class Count implements Serializable - { - private String _name = null; - private long _count = 0; - // hang onto the FacetField for breadcrumb creation convenience - private FacetField _ff = null; - - public Count( FacetField ff, String n, long c ) - { - _name = n; - _count = c; - _ff = ff; - } - - public String getName() { - return _name; - } - - public void setName( String n ) - { - _name = n; - } - - public long getCount() { - return _count; - } - - public void setCount( long c ) - { - _count = c; - } - - public FacetField getFacetField() { - return _ff; - } - - @Override - public String toString() - { - return _name+" ("+_count+")"; - } - - public String getAsFilterQuery() { - if (_ff.getName().equals("facet_queries")) { - return _name; - } - return - ClientUtils.escapeQueryChars( _ff._name ) + ":" + - ClientUtils.escapeQueryChars( _name ); - } - } - - private String _name = null; - private List<Count> _values = null; - private String _gap = null; - private Date _end = null; - - public FacetField( final String n ) - { - _name = n; - } - - public FacetField(String name, String gap, Date end) { - _name = name; - _gap = gap; - _end = end; - } - - /** - * Date Gap Facet parameter - * - * @return the value specified for facet.date.gap - */ - public String getGap() { - return _gap; - } - - /** - * Date End Facet parameter - * - * @return the value specified for facet.date.end - */ - public Date getEnd() { - return _end; - } - - /** - * Insert at the end of the list - */ - public void add( String name, long cnt ) - { - if( _values == null ) { - _values = new ArrayList<>( 30 ); - } - _values.add( new Count( this, name, cnt ) ); - } - - /** - * Insert at the beginning of the list. - */ - public void insert( String name, long cnt ) - { - if( _values == null ) { - _values = new ArrayList<>( 30 ); - } - _values.add( 0, new Count( this, name, cnt ) ); - } - - public String getName() { - return _name; - } - - public List<Count> getValues() { - return _values == null ? Collections.<Count>emptyList() : _values; - } - - public int getValueCount() - { - return _values == null ? 0 : _values.size(); - } - - public FacetField getLimitingFields(long max) - { - FacetField ff = new FacetField( _name ); - if( _values != null ) { - ff._values = new ArrayList<>( _values.size() ); - for( Count c : _values ) { - if( c._count < max ) { // !equal to - ff._values.add( c ); - } - } - } - return ff; - } - - @Override - public String toString() - { - return _name + ":" + _values; - } - } http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java deleted file mode 100644 index 9c542d7..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldAnalysisResponse.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.common.util.NamedList; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * A response that is returned by processing the {@link org.apache.solr.client.solrj.request.FieldAnalysisRequest}. - * Holds a map of {@link Analysis} objects per field name as well as a map of {@link Analysis} objects per field type. - * - * - * @since solr 1.4 - */ -public class FieldAnalysisResponse extends AnalysisResponseBase { - - private Map<String, Analysis> analysisByFieldTypeName = new HashMap<>(); - private Map<String, Analysis> analysisByFieldName = new HashMap<>(); - - /** - * {@inheritDoc} - */ - @Override - public void setResponse(NamedList<Object> response) { - super.setResponse(response); - - @SuppressWarnings("unchecked") - NamedList<NamedList<NamedList<NamedList<List<NamedList<Object>>>>>> analysisNL - = (NamedList<NamedList<NamedList<NamedList<List<NamedList<Object>>>>>>) response.get("analysis"); - - for (Map.Entry<String, NamedList<NamedList<List<NamedList<Object>>>>> entry - : analysisNL.get("field_types")) { - - analysisByFieldTypeName.put(entry.getKey(), buildAnalysis(entry.getValue())); - } - - for (Map.Entry<String, NamedList<NamedList<List<NamedList<Object>>>>> entry - : analysisNL.get("field_names")) { - - analysisByFieldName.put(entry.getKey(), buildAnalysis(entry.getValue())); - } - } - - private Analysis buildAnalysis(NamedList<NamedList<List<NamedList<Object>>>> value) { - Analysis analysis = new Analysis(); - - NamedList<List<NamedList<Object>>> queryNL = value.get("query"); - List<AnalysisPhase> phases = (queryNL == null) ? null : buildPhases(queryNL); - analysis.setQueryPhases(phases); - - NamedList<List<NamedList<Object>>> indexNL = value.get("index"); - phases = buildPhases(indexNL); - analysis.setIndexPhases(phases); - - return analysis; - } - - /** - * Returns the number of field type analyses. - * - * @return The number of field type analyses. - */ - public int getFieldTypeAnalysisCount() { - return analysisByFieldTypeName.size(); - } - - /** - * Returns the analysis for the given field type or {@code null} if no such analysis exists. - * - * @param fieldTypeName The name of the field type. - * - * @return The analysis for the given field type. - */ - public Analysis getFieldTypeAnalysis(String fieldTypeName) { - return analysisByFieldTypeName.get(fieldTypeName); - } - - /** - * Returns all field type analyses with their associated field types. - * - * @return All field type analyses with their associated field types. - */ - public Iterable<Map.Entry<String, Analysis>> getAllFieldTypeAnalysis() { - return analysisByFieldTypeName.entrySet(); - } - - /** - * Returns the number of field name analyses. - * - * @return The number of field name analyses. - */ - public int getFieldNameAnalysisCount() { - return analysisByFieldName.size(); - } - - /** - * Returns the analysis for the given field name or {@code null} if no such analysis exists. - * - * @param fieldName The field name. - * - * @return The analysis for the given field name. - */ - public Analysis getFieldNameAnalysis(String fieldName) { - return analysisByFieldName.get(fieldName); - } - - /** - * Returns all field name analysese with their associated field names. - * - * @return all field name analysese with their associated field names. - */ - public Iterable<Map.Entry<String, Analysis>> getAllFieldNameAnalysis() { - return analysisByFieldName.entrySet(); - } - - - //================================================= Inner Classes ================================================== - - /** - * The analysis of a field. Holds a list of all the query time analysis phases (if a query analysis was requested) - * as well as index time phases. - */ - public static class Analysis { - - private List<AnalysisPhase> queryPhases; - private List<AnalysisPhase> indexPhases; - - /** - * This class should only be instantiated internally. - */ - private Analysis() { - } - - /** - * Returns the number of query time analysis phases in this analysis or - * {@code -1} if query time analysis doesn't exist. - * - * @return Returns the number of query time analysis phases in this - * analysis or {@code -1} if query time analysis doesn't exist. - */ - public int getQueryPhasesCount() { - return queryPhases == null ? -1 : queryPhases.size(); - } - - /** - * Returns the query time analysis phases for this analysis or {@code null} - * if query time analysis doesn't exist. - * - * - * @return The query time analysis phases for this analysis or {@code null} - * if query time analysis doesn't exist. - * - */ - public Iterable<AnalysisPhase> getQueryPhases() { - return queryPhases; - } - - /** - * Returns the index time analysis phases for this analysis. - * - * @return The index time analysis phases for this analysis. - */ - public int getIndexPhasesCount() { - return indexPhases.size(); - } - - /** - * Returns the index time analysis phases for this analysis. - * - * @return The index time analysis phases for this analysis. - */ - public Iterable<AnalysisPhase> getIndexPhases() { - return indexPhases; - } - - private void setQueryPhases(List<AnalysisPhase> queryPhases) { - this.queryPhases = queryPhases; - } - - private void setIndexPhases(List<AnalysisPhase> indexPhases) { - this.indexPhases = indexPhases; - } - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldStatsInfo.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldStatsInfo.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldStatsInfo.java deleted file mode 100644 index 9685832..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/FieldStatsInfo.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.common.util.NamedList; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Holds stats info - * - * - * @since solr 1.4 - */ -public class FieldStatsInfo implements Serializable { - final String name; - - Object min; - Object max; - Object sum; - Long count; - Long countDistinct; - Collection<Object> distinctValues; - Long missing; - Object mean = null; - Double sumOfSquares = null; - Double stddev = null; - - Map<String,List<FieldStatsInfo>> facets; - - public FieldStatsInfo( NamedList<Object> nl, String fname ) - { - name = fname; - - for( Map.Entry<String, Object> entry : nl ) { - if( "min".equals( entry.getKey() ) ) { - min = entry.getValue(); - } - else if( "max".equals( entry.getKey() ) ) { - max = entry.getValue(); - } - else if( "sum".equals( entry.getKey() ) ) { - sum = entry.getValue(); - } - else if( "count".equals( entry.getKey() ) ) { - count = (Long)entry.getValue(); - } - else if ("countDistinct".equals(entry.getKey())) { - countDistinct = (Long) entry.getValue(); - } - else if ("distinctValues".equals(entry.getKey())) { - distinctValues = (Collection<Object>) entry.getValue(); - } - else if( "missing".equals( entry.getKey() ) ) { - missing = (Long)entry.getValue(); - } - else if( "mean".equals( entry.getKey() ) ) { - mean = entry.getValue(); - } - else if( "sumOfSquares".equals( entry.getKey() ) ) { - sumOfSquares = (Double)entry.getValue(); - } - else if( "stddev".equals( entry.getKey() ) ) { - stddev = (Double)entry.getValue(); - } - else if( "facets".equals( entry.getKey() ) ) { - @SuppressWarnings("unchecked") - NamedList<Object> fields = (NamedList<Object>)entry.getValue(); - facets = new HashMap<>(); - for( Map.Entry<String, Object> ev : fields ) { - List<FieldStatsInfo> vals = new ArrayList<>(); - facets.put( ev.getKey(), vals ); - @SuppressWarnings("unchecked") - NamedList<NamedList<Object>> vnl = (NamedList<NamedList<Object>>) ev.getValue(); - for( int i=0; i<vnl.size(); i++ ) { - String n = vnl.getName(i); - vals.add( new FieldStatsInfo( vnl.getVal(i), n ) ); - } - } - } - else { - throw new RuntimeException( "unknown key: "+entry.getKey() + " ["+entry.getValue()+"]" ); - } - } - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append( name ); - sb.append( ": {" ); - if( min != null ) { - sb.append( " min:").append( min ); - } - if( max != null ) { - sb.append( " max:").append( max ); - } - if( sum != null ) { - sb.append( " sum:").append( sum ); - } - if( count != null ) { - sb.append( " count:").append( count ); - } - if (countDistinct != null) { - sb.append(" countDistinct:").append(countDistinct); - } - if (distinctValues != null) { - sb.append(" distinctValues:").append(distinctValues); - } - if( missing != null ) { - sb.append( " missing:").append( missing ); - } - if( mean != null ) { - sb.append( " mean:").append( mean ); - } - if( stddev != null ) { - sb.append( " stddev:").append(stddev); - } - sb.append( " }" ); - return sb.toString(); - } - - public String getName() { - return name; - } - - public Object getMin() { - return min; - } - - public Object getMax() { - return max; - } - - public Object getSum() { - return sum; - } - - public Long getCount() { - return count; - } - - public Long getCountDistinct() { - return countDistinct; - } - - public Collection<Object> getDistinctValues() { - return distinctValues; - } - - public Long getMissing() { - return missing; - } - - public Object getMean() { - return mean; - } - - public Double getStddev() { - return stddev; - } - - public Double getSumOfSquares() { - return sumOfSquares; - } - - public Map<String, List<FieldStatsInfo>> getFacets() { - return facets; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/Group.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/Group.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/Group.java deleted file mode 100644 index bc4271a..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/Group.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.common.SolrDocumentList; - -import java.io.Serializable; - -/** - * Represents a group. A group contains a common group value that all documents inside the group share and - * documents that belong to this group. - * - * A group value can be a field value, function result or a query string depending on the {@link GroupCommand}. - * In case of a field value or a function result the value is always a indexed value. - * - * @since solr 3.4 - */ -public class Group implements Serializable { - - private final String _groupValue; - private final SolrDocumentList _result; - - /** - * Creates a Group instance. - * - * @param groupValue The common group value (indexed value) that all documents share. - * @param result The documents to be displayed that belong to this group - */ - public Group(String groupValue, SolrDocumentList result) { - _groupValue = groupValue; - _result = result; - } - - /** - * Returns the common group value that all documents share inside this group. - * This is an indexed value, not a stored value. - * - * @return the common group value - */ - public String getGroupValue() { - return _groupValue; - } - - /** - * Returns the documents to be displayed that belong to this group. - * How many documents are returned depend on the <code>group.offset</code> and <code>group.limit</code> parameters. - * - * @return the documents to be displayed that belong to this group - */ - public SolrDocumentList getResult() { - return _result; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupCommand.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupCommand.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupCommand.java deleted file mode 100644 index 58bb9cb..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupCommand.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * This class represents the result of a group command. - * This can be the result of the following parameter: - * <ul> - * <li> group.field - * <li> group.func - * <li> group.query - * </ul> - * - * An instance of this class contains: - * <ul> - * <li> The name of this command. This can be the field, function or query grouped by. - * <li> The total number of documents that have matched. - * <li> The total number of groups that have matched. - * <li> The groups to be displayed. Depending on the start and rows parameter. - * </ul> - * - * In case of <code>group.query</code> only one group is present and ngroups is always <code>null</code>. - * - * @since solr 3.4 - */ -public class GroupCommand implements Serializable { - - private final String _name; - private final List<Group> _values = new ArrayList<>(); - private final int _matches; - private final Integer _ngroups; - - /** - * Creates a GroupCommand instance - * - * @param name The name of this command - * @param matches The total number of documents found for this command - */ - public GroupCommand(String name, int matches) { - _name = name; - _matches = matches; - _ngroups = null; - } - - /** - * Creates a GroupCommand instance. - * - * @param name The name of this command - * @param matches The total number of documents found for this command - * @param nGroups The total number of groups found for this command. - */ - public GroupCommand(String name, int matches, int nGroups) { - _name = name; - _matches = matches; - _ngroups = nGroups; - } - - /** - * Returns the name of this command. This can be the field, function or query grouped by. - * - * @return the name of this command - */ - public String getName() { - return _name; - } - - /** - * Adds a group to this command. - * - * @param group A group to be added - */ - public void add(Group group) { - _values.add(group); - } - - /** - * Returns the groups to be displayed. - * The number of groups returned depend on the <code>start</code> and <code>rows</code> parameters. - * - * @return the groups to be displayed. - */ - public List<Group> getValues() { - return _values; - } - - /** - * Returns the total number of documents found for this command. - * - * @return the total number of documents found for this command. - */ - public int getMatches() { - return _matches; - } - - /** - * Returns the total number of groups found for this command. - * Returns <code>null</code> if the <code>group.ngroups</code> parameter is unset or <code>false</code> or - * if this is a group command query (parameter = <code>group.query</code>). - * - * @return the total number of groups found for this command. - */ - public Integer getNGroups() { - return _ngroups; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupResponse.java deleted file mode 100644 index 3549101..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/GroupResponse.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * Overall grouping result. Contains a list of {@link GroupCommand} instances that is the result of - * one the following parameters: - * <ul> - * <li>group.field - * <li>group.func - * <li>group.query - * </ul> - * - * @since solr 3.4 - */ -public class GroupResponse implements Serializable { - - private final List<GroupCommand> _values = new ArrayList<>(); - - /** - * Adds a grouping command to the response. - * - * @param command The grouping command to add - */ - public void add(GroupCommand command) { - _values.add(command); - } - - /** - * Returns all grouping commands. - * - * @return all grouping commands - */ - public List<GroupCommand> getValues() { - return _values; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/IntervalFacet.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/IntervalFacet.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/IntervalFacet.java deleted file mode 100644 index b6ec6c3..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/IntervalFacet.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.util.List; - -/** - * Objects of this class will contain the result of all the intervals defined - * for a specific field. - */ -public class IntervalFacet { - - /** - * The field for which interval facets where calculated - */ - private final String field; - - /** - * The list of interval facets calculated for {@link #field} - */ - private final List<Count> intervals; - - IntervalFacet(String field, List<Count> values) { - this.field = field; - this.intervals = values; - } - - /** - * @return The field for which interval facets where calculated - */ - public String getField() { - return field; - } - - /** - * @return The list of interval facets calculated for {@link #field} - */ - public List<Count> getIntervals() { - return intervals; - } - - /** - * Holds counts for facet intervals defined in a field - */ - public static class Count { - /** - * The key of this interval. This is the original - * interval string or the value of the "key" local - * param - */ - private final String key; - /** - * The count of this interval - */ - private final int count; - - Count(String key, int count) { - super(); - this.key = key; - this.count = count; - } - - public String getKey() { - return key; - } - - public int getCount() { - return count; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/LukeResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/LukeResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/LukeResponse.java deleted file mode 100644 index 5d2f328..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/LukeResponse.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.common.luke.FieldFlag; -import org.apache.solr.common.util.NamedList; - -import java.io.Serializable; -import java.util.*; - - -/** - * This is an incomplete representation of the data returned from Luke - * - * - * @since solr 1.3 - */ -public class LukeResponse extends SolrResponseBase { - - public static class FieldTypeInfo implements Serializable { - String name; - String className; - boolean tokenized; - String analyzer; - List<String> fields; - - - public FieldTypeInfo(String name) { - this.name = name; - fields = Collections.emptyList(); - } - - - public String getAnalyzer() { - return analyzer; - } - - public String getClassName() { - return className; - } - - public List<String> getFields() { - return fields; - } - - public String getName() { - return name; - } - - public boolean isTokenized() { - return tokenized; - }/* - Sample: - types={ignored={fields=null,tokenized=false,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@f94934}, - integer={fields=null,tokenized=false,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@3525a2}, - sfloat={fields=[price, weight],tokenized=false,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@39cf9c}, - text_ws={fields=[cat],tokenized=true,analyzer=TokenizerChain(org.apache.solr.analysis.WhitespaceTokenizerFactory@6d3ca2)}, - alphaOnlySort={fields=[alphaNameSort],tokenized=true,analyzer=TokenizerChain(org.apache.solr.analysis.KeywordTokenizerFactory@a7bd3b, - org.apache.solr.analysis.LowerCaseFilterFactory@78aae2, org.apache.solr.analysis.TrimFilterFactory@1b16a7, - org.apache.solr.analysis.PatternReplaceFilterFactory@6c6b08)},date={fields=[timestamp],tokenized=false, - analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@e6e42e},sint={fields=[popularity], - tokenized=false,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@8ea21d}, - boolean={fields=[inStock],tokenized=false,analyzer=org.apache.solr.schema.BoolField$1@354949}, - textTight={fields=[sku],tokenized=true,analyzer=TokenizerChain(org.apache.solr.analysis.WhitespaceTokenizerFactory@5e88f7, - org.apache.solr.analysis.SynonymFilterFactory@723646, org.apache.solr.analysis.StopFilterFactory@492ff1, - org.apache.solr.analysis.WordDelimiterFilterFactory@eaabad, org.apache.solr.analysis.LowerCaseFilterFactory@ad1355, - org.apache.solr.analysis.EnglishPorterFilterFactory@d03a00, org.apache.solr.analysis.RemoveDuplicatesTokenFilterFactory@900079)}, - long={fields=null,tokenized=false,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@f3b83}, - double={fields=null,tokenized=false,analyzer=org.apache.solr.schema.FieldType$DefaultAnalyzer@c2b07}, - - */ - - @SuppressWarnings("unchecked") - public void read(NamedList<Object> nl) { - for (Map.Entry<String, Object> entry : nl) { - String key = entry.getKey(); - if ("fields".equals(key) && entry.getValue() != null) { - List<String> theFields = (List<String>) entry.getValue(); - fields = new ArrayList<>(theFields); - } else if ("tokenized".equals(key) == true) { - tokenized = Boolean.parseBoolean(entry.getValue().toString()); - } else if ("analyzer".equals(key) == true) { - analyzer = entry.getValue().toString(); - } else if ("className".equals(key) == true) { - className = entry.getValue().toString(); - } - } - } - } - - public static class FieldInfo implements Serializable { - String name; - String type; - String schema; - int docs; - int distinct; - EnumSet<FieldFlag> flags; - boolean cacheableFaceting; - NamedList<Integer> topTerms; - - public FieldInfo(String n) { - name = n; - } - - @SuppressWarnings("unchecked") - public void read(NamedList<Object> nl) { - for (Map.Entry<String, Object> entry : nl) { - if ("type".equals(entry.getKey())) { - type = (String) entry.getValue(); - } - if ("flags".equals(entry.getKey())) { - flags = parseFlags((String) entry.getValue()); - } else if ("schema".equals(entry.getKey())) { - schema = (String) entry.getValue(); - } else if ("docs".equals(entry.getKey())) { - docs = (Integer) entry.getValue(); - } else if ("distinct".equals(entry.getKey())) { - distinct = (Integer) entry.getValue(); - } else if ("cacheableFaceting".equals(entry.getKey())) { - cacheableFaceting = (Boolean) entry.getValue(); - } else if ("topTerms".equals(entry.getKey())) { - topTerms = (NamedList<Integer>) entry.getValue(); - } - } - } - - public static EnumSet<FieldFlag> parseFlags(String flagStr) { - EnumSet<FieldFlag> result = EnumSet.noneOf(FieldFlag.class); - char[] chars = flagStr.toCharArray(); - for (int i = 0; i < chars.length; i++) { - if (chars[i] != '-') { - FieldFlag flag = FieldFlag.getFlag(chars[i]); - result.add(flag); - } - } - return result; - } - - public EnumSet<FieldFlag> getFlags() { - return flags; - } - - public boolean isCacheableFaceting() { - return cacheableFaceting; - } - - public String getType() { - return type; - } - - public int getDistinct() { - return distinct; - } - - public int getDocs() { - return docs; - } - - public String getName() { - return name; - } - - public String getSchema() { - return schema; - } - - public NamedList<Integer> getTopTerms() { - return topTerms; - } - } - - private NamedList<Object> indexInfo; - private Map<String, FieldInfo> fieldInfo; - private Map<String, FieldTypeInfo> fieldTypeInfo; - - @Override - @SuppressWarnings("unchecked") - public void setResponse(NamedList<Object> res) { - super.setResponse(res); - - // Parse indexinfo - indexInfo = (NamedList<Object>) res.get("index"); - - NamedList<Object> schema = (NamedList<Object>) res.get("schema"); - NamedList<Object> flds = (NamedList<Object>) res.get("fields"); - if (flds == null && schema != null ) { - flds = (NamedList<Object>) schema.get("fields"); - } - if (flds != null) { - fieldInfo = new HashMap<>(); - for (Map.Entry<String, Object> field : flds) { - FieldInfo f = new FieldInfo(field.getKey()); - f.read((NamedList<Object>) field.getValue()); - fieldInfo.put(field.getKey(), f); - } - } - - if( schema != null ) { - NamedList<Object> fldTypes = (NamedList<Object>) schema.get("types"); - if (fldTypes != null) { - fieldTypeInfo = new HashMap<>(); - for (Map.Entry<String, Object> fieldType : fldTypes) { - FieldTypeInfo ft = new FieldTypeInfo(fieldType.getKey()); - ft.read((NamedList<Object>) fieldType.getValue()); - fieldTypeInfo.put(fieldType.getKey(), ft); - } - } - } - } - - //---------------------------------------------------------------- - //---------------------------------------------------------------- - - public String getIndexDirectory() { - if (indexInfo == null) return null; - return (String) indexInfo.get("directory"); - } - - public Integer getNumDocs() { - if (indexInfo == null) return null; - return (Integer) indexInfo.get("numDocs"); - } - - public Integer getMaxDoc() { - if (indexInfo == null) return null; - return (Integer) indexInfo.get("maxDoc"); - } - - public Integer getNumTerms() { - if (indexInfo == null) return null; - return (Integer) indexInfo.get("numTerms"); - } - - public Map<String, FieldTypeInfo> getFieldTypeInfo() { - return fieldTypeInfo; - } - - public FieldTypeInfo getFieldTypeInfo(String name) { - return fieldTypeInfo.get(name); - } - - public NamedList<Object> getIndexInfo() { - return indexInfo; - } - - public Map<String, FieldInfo> getFieldInfo() { - return fieldInfo; - } - - public FieldInfo getFieldInfo(String f) { - return fieldInfo.get(f); - } - - //---------------------------------------------------------------- -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/PivotField.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/PivotField.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/PivotField.java deleted file mode 100644 index 3b084f6..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/PivotField.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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.client.solrj.response; - -import java.io.PrintStream; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -public class PivotField implements Serializable -{ - final String _field; - final Object _value; - final int _count; - final List<PivotField> _pivot; - final Map<String,FieldStatsInfo> _statsInfo; - - /** - * @deprecated Use {@link #PivotField(String,Object,int,List,Map)} with a null <code>statsInfo</code> - */ - @Deprecated - public PivotField( String f, Object v, int count, List<PivotField> pivot) { - this(f, v, count, pivot, null); - } - - public PivotField( String f, Object v, int count, List<PivotField> pivot, Map<String,FieldStatsInfo> statsInfo) - { - _field = f; - _value = v; - _count = count; - _pivot = pivot; - _statsInfo = statsInfo; - } - - public String getField() { - return _field; - } - - public Object getValue() { - return _value; - } - - public int getCount() { - return _count; - } - - public List<PivotField> getPivot() { - return _pivot; - } - - public Map<String,FieldStatsInfo> getFieldStatsInfo() { - return _statsInfo; - } - - @Override - public String toString() - { - return _field + ":" + _value + " ["+_count+"] "+_pivot; - } - - public void write( PrintStream out, int indent ) - { - for( int i=0; i<indent; i++ ) { - out.print( " " ); - } - out.print( _field + "=" + _value + " ("+_count+")" ); - if (null != _statsInfo) { - out.print( "->stats:[" ); - for( FieldStatsInfo fieldStatsInfo : _statsInfo.values() ) { - out.print(fieldStatsInfo.toString()); - out.print(","); - } - out.print("]"); - } - out.println(); - if( _pivot != null ) { - for( PivotField p : _pivot ) { - p.write( out, indent+1 ); - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/d9a661cf/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/QueryResponse.java ---------------------------------------------------------------------- diff --git a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/QueryResponse.java b/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/QueryResponse.java deleted file mode 100644 index 89cd971..0000000 --- a/ranger_solrj/src/main/java/org/apache/solr/client/solrj/response/QueryResponse.java +++ /dev/null @@ -1,586 +0,0 @@ -/* - * 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.client.solrj.response; - -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.beans.DocumentObjectBinder; -import org.apache.solr.common.SolrDocumentList; -import org.apache.solr.common.params.CursorMarkParams; -import org.apache.solr.common.util.NamedList; -import org.apache.solr.common.util.SimpleOrderedMap; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * - * - * @since solr 1.3 - */ -@SuppressWarnings("unchecked") -public class QueryResponse extends SolrResponseBase -{ - // Direct pointers to known types - private NamedList<Object> _header = null; - private SolrDocumentList _results = null; - private NamedList<ArrayList> _sortvalues = null; - private NamedList<Object> _facetInfo = null; - private NamedList<Object> _debugInfo = null; - private NamedList<Object> _highlightingInfo = null; - private NamedList<Object> _spellInfo = null; - private NamedList<Object> _statsInfo = null; - private NamedList<NamedList<Number>> _termsInfo = null; - private String _cursorMarkNext = null; - - // Grouping response - private NamedList<Object> _groupedInfo = null; - private GroupResponse _groupResponse = null; - - private NamedList<Object> _expandedInfo = null; - private Map<String, SolrDocumentList> _expandedResults = null; - - // Facet stuff - private Map<String,Integer> _facetQuery = null; - private List<FacetField> _facetFields = null; - private List<FacetField> _limitingFacets = null; - private List<FacetField> _facetDates = null; - private List<RangeFacet> _facetRanges = null; - private NamedList<List<PivotField>> _facetPivot = null; - private List<IntervalFacet> _intervalFacets = null; - - // Highlight Info - private Map<String,Map<String,List<String>>> _highlighting = null; - - // SpellCheck Response - private SpellCheckResponse _spellResponse = null; - - // Terms Response - private TermsResponse _termsResponse = null; - - // Field stats Response - private Map<String,FieldStatsInfo> _fieldStatsInfo = null; - - // Debug Info - private Map<String,Object> _debugMap = null; - private Map<String,String> _explainMap = null; - - // utility variable used for automatic binding -- it should not be serialized - private transient final SolrClient solrClient; - - public QueryResponse(){ - solrClient = null; - } - - /** - * Utility constructor to set the solrServer and namedList - */ - public QueryResponse( NamedList<Object> res , SolrClient solrClient){ - this.setResponse( res ); - this.solrClient = solrClient; - } - - public QueryResponse(SolrClient solrClient) { - this.solrClient = solrClient; - } - - @Override - public void setResponse( NamedList<Object> res ) - { - super.setResponse( res ); - - // Look for known things - for( int i=0; i<res.size(); i++ ) { - String n = res.getName( i ); - if( "responseHeader".equals( n ) ) { - _header = (NamedList<Object>) res.getVal( i ); - } - else if( "response".equals( n ) ) { - _results = (SolrDocumentList) res.getVal( i ); - } - else if( "sort_values".equals( n ) ) { - _sortvalues = (NamedList<ArrayList>) res.getVal( i ); - } - else if( "facet_counts".equals( n ) ) { - _facetInfo = (NamedList<Object>) res.getVal( i ); - // extractFacetInfo inspects _results, so defer calling it - // in case it hasn't been populated yet. - } - else if( "debug".equals( n ) ) { - _debugInfo = (NamedList<Object>) res.getVal( i ); - extractDebugInfo( _debugInfo ); - } - else if( "grouped".equals( n ) ) { - _groupedInfo = (NamedList<Object>) res.getVal( i ); - extractGroupedInfo( _groupedInfo ); - } - else if("expanded".equals(n)) { - _expandedResults = (Map<String, SolrDocumentList>) res.getVal( i ); - } - else if( "highlighting".equals( n ) ) { - _highlightingInfo = (NamedList<Object>) res.getVal( i ); - extractHighlightingInfo( _highlightingInfo ); - } - else if ( "spellcheck".equals( n ) ) { - _spellInfo = (NamedList<Object>) res.getVal( i ); - extractSpellCheckInfo( _spellInfo ); - } - else if ( "stats".equals( n ) ) { - _statsInfo = (NamedList<Object>) res.getVal( i ); - extractStatsInfo( _statsInfo ); - } - else if ( "terms".equals( n ) ) { - _termsInfo = (NamedList<NamedList<Number>>) res.getVal( i ); - extractTermsInfo( _termsInfo ); - } - else if ( CursorMarkParams.CURSOR_MARK_NEXT.equals( n ) ) { - _cursorMarkNext = (String) res.getVal( i ); - } - } - if(_facetInfo != null) extractFacetInfo( _facetInfo ); - } - - private void extractSpellCheckInfo(NamedList<Object> spellInfo) { - _spellResponse = new SpellCheckResponse(spellInfo); - } - - private void extractTermsInfo(NamedList<NamedList<Number>> termsInfo) { - _termsResponse = new TermsResponse(termsInfo); - } - - private void extractStatsInfo(NamedList<Object> info) { - _fieldStatsInfo = extractFieldStatsInfo(info); - } - - private Map<String, FieldStatsInfo> extractFieldStatsInfo(NamedList<Object> info) { - if( info != null ) { - Map<String, FieldStatsInfo> fieldStatsInfoMap = new TreeMap<>(); - NamedList<NamedList<Object>> ff = (NamedList<NamedList<Object>>) info.get( "stats_fields" ); - if( ff != null ) { - for( Map.Entry<String,NamedList<Object>> entry : ff ) { - NamedList<Object> v = entry.getValue(); - if( v != null ) { - fieldStatsInfoMap.put( entry.getKey(), - new FieldStatsInfo( v, entry.getKey() ) ); - } - } - } - return fieldStatsInfoMap; - } - return null; - } - - private void extractDebugInfo( NamedList<Object> debug ) - { - _debugMap = new LinkedHashMap<>(); // keep the order - for( Map.Entry<String, Object> info : debug ) { - _debugMap.put( info.getKey(), info.getValue() ); - } - - // Parse out interesting bits from the debug info - _explainMap = new HashMap<>(); - NamedList<String> explain = (NamedList<String>)_debugMap.get( "explain" ); - if( explain != null ) { - for( Map.Entry<String, String> info : explain ) { - String key = info.getKey(); - _explainMap.put( key, info.getValue() ); - } - } - } - - private void extractGroupedInfo( NamedList<Object> info ) { - if ( info != null ) { - _groupResponse = new GroupResponse(); - int size = info.size(); - for (int i=0; i < size; i++) { - String fieldName = info.getName(i); - Object fieldGroups = info.getVal(i); - SimpleOrderedMap<Object> simpleOrderedMap = (SimpleOrderedMap<Object>) fieldGroups; - - Object oMatches = simpleOrderedMap.get("matches"); - Object oNGroups = simpleOrderedMap.get("ngroups"); - Object oGroups = simpleOrderedMap.get("groups"); - Object queryCommand = simpleOrderedMap.get("doclist"); - if (oMatches == null) { - continue; - } - - if (oGroups != null) { - Integer iMatches = (Integer) oMatches; - ArrayList<Object> groupsArr = (ArrayList<Object>) oGroups; - GroupCommand groupedCommand; - if (oNGroups != null) { - Integer iNGroups = (Integer) oNGroups; - groupedCommand = new GroupCommand(fieldName, iMatches, iNGroups); - } else { - groupedCommand = new GroupCommand(fieldName, iMatches); - } - - for (Object oGrp : groupsArr) { - SimpleOrderedMap grpMap = (SimpleOrderedMap) oGrp; - Object sGroupValue = grpMap.get( "groupValue"); - SolrDocumentList doclist = (SolrDocumentList) grpMap.get( "doclist"); - Group group = new Group(sGroupValue != null ? sGroupValue.toString() : null, doclist) ; - groupedCommand.add(group); - } - - _groupResponse.add(groupedCommand); - } else if (queryCommand != null) { - Integer iMatches = (Integer) oMatches; - GroupCommand groupCommand; - if (oNGroups != null) { - Integer iNGroups = (Integer) oNGroups; - groupCommand = new GroupCommand(fieldName, iMatches, iNGroups); - } else { - groupCommand = new GroupCommand(fieldName, iMatches); - } - SolrDocumentList docList = (SolrDocumentList) queryCommand; - groupCommand.add(new Group(fieldName, docList)); - _groupResponse.add(groupCommand); - } - } - } - } - - private void extractHighlightingInfo( NamedList<Object> info ) - { - _highlighting = new HashMap<>(); - for( Map.Entry<String, Object> doc : info ) { - Map<String,List<String>> fieldMap = new HashMap<>(); - _highlighting.put( doc.getKey(), fieldMap ); - - NamedList<List<String>> fnl = (NamedList<List<String>>)doc.getValue(); - for( Map.Entry<String, List<String>> field : fnl ) { - fieldMap.put( field.getKey(), field.getValue() ); - } - } - } - - private void extractFacetInfo( NamedList<Object> info ) - { - // Parse the queries - _facetQuery = new LinkedHashMap<>(); - NamedList<Integer> fq = (NamedList<Integer>) info.get( "facet_queries" ); - if (fq != null) { - for( Map.Entry<String, Integer> entry : fq ) { - _facetQuery.put( entry.getKey(), entry.getValue() ); - } - } - - // Parse the facet info into fields - // TODO?? The list could be <int> or <long>? If always <long> then we can switch to <Long> - NamedList<NamedList<Number>> ff = (NamedList<NamedList<Number>>) info.get( "facet_fields" ); - if( ff != null ) { - _facetFields = new ArrayList<>( ff.size() ); - _limitingFacets = new ArrayList<>( ff.size() ); - - long minsize = _results == null ? Long.MAX_VALUE :_results.getNumFound(); - for( Map.Entry<String,NamedList<Number>> facet : ff ) { - FacetField f = new FacetField( facet.getKey() ); - for( Map.Entry<String, Number> entry : facet.getValue() ) { - f.add( entry.getKey(), entry.getValue().longValue() ); - } - - _facetFields.add( f ); - FacetField nl = f.getLimitingFields( minsize ); - if( nl.getValueCount() > 0 ) { - _limitingFacets.add( nl ); - } - } - } - - //Parse date facets - NamedList<NamedList<Object>> df = (NamedList<NamedList<Object>>) info.get("facet_dates"); - if (df != null) { - // System.out.println(df); - _facetDates = new ArrayList<>( df.size() ); - for (Map.Entry<String, NamedList<Object>> facet : df) { - // System.out.println("Key: " + facet.getKey() + " Value: " + facet.getValue()); - NamedList<Object> values = facet.getValue(); - String gap = (String) values.get("gap"); - Date end = (Date) values.get("end"); - FacetField f = new FacetField(facet.getKey(), gap, end); - - for (Map.Entry<String, Object> entry : values) { - try { - f.add(entry.getKey(), Long.parseLong(entry.getValue().toString())); - } catch (NumberFormatException e) { - //Ignore for non-number responses which are already handled above - } - } - - _facetDates.add(f); - } - } - - //Parse range facets - NamedList<NamedList<Object>> rf = (NamedList<NamedList<Object>>) info.get("facet_ranges"); - if (rf != null) { - _facetRanges = new ArrayList<>( rf.size() ); - for (Map.Entry<String, NamedList<Object>> facet : rf) { - NamedList<Object> values = facet.getValue(); - Object rawGap = values.get("gap"); - - RangeFacet rangeFacet; - if (rawGap instanceof Number) { - Number gap = (Number) rawGap; - Number start = (Number) values.get("start"); - Number end = (Number) values.get("end"); - - Number before = (Number) values.get("before"); - Number after = (Number) values.get("after"); - Number between = (Number) values.get("between"); - - rangeFacet = new RangeFacet.Numeric(facet.getKey(), start, end, gap, before, after, between); - } else { - String gap = (String) rawGap; - Date start = (Date) values.get("start"); - Date end = (Date) values.get("end"); - - Number before = (Number) values.get("before"); - Number after = (Number) values.get("after"); - Number between = (Number) values.get("between"); - - rangeFacet = new RangeFacet.Date(facet.getKey(), start, end, gap, before, after, between); - } - - NamedList<Integer> counts = (NamedList<Integer>) values.get("counts"); - for (Map.Entry<String, Integer> entry : counts) { - rangeFacet.addCount(entry.getKey(), entry.getValue()); - } - - _facetRanges.add(rangeFacet); - } - } - - //Parse pivot facets - NamedList pf = (NamedList) info.get("facet_pivot"); - if (pf != null) { - _facetPivot = new NamedList<>(); - for( int i=0; i<pf.size(); i++ ) { - _facetPivot.add( pf.getName(i), readPivots( (List<NamedList>)pf.getVal(i) ) ); - } - } - - //Parse interval facets - NamedList<NamedList<Object>> intervalsNL = (NamedList<NamedList<Object>>) info.get("facet_intervals"); - if (intervalsNL != null) { - _intervalFacets = new ArrayList<>(intervalsNL.size()); - for (Map.Entry<String, NamedList<Object>> intervalField : intervalsNL) { - String field = intervalField.getKey(); - List<IntervalFacet.Count> counts = new ArrayList<IntervalFacet.Count>(intervalField.getValue().size()); - for (Map.Entry<String, Object> interval : intervalField.getValue()) { - counts.add(new IntervalFacet.Count(interval.getKey(), (Integer)interval.getValue())); - } - _intervalFacets.add(new IntervalFacet(field, counts)); - } - } - } - - protected List<PivotField> readPivots( List<NamedList> list ) - { - ArrayList<PivotField> values = new ArrayList<>( list.size() ); - for( NamedList nl : list ) { - // NOTE, this is cheating, but we know the order they are written in, so no need to check - assert "field".equals(nl.getName(0)); - String f = (String)nl.getVal( 0 ); - assert "value".equals(nl.getName(1)); - Object v = nl.getVal( 1 ); - assert "count".equals(nl.getName(2)); - int cnt = ((Integer)nl.getVal( 2 )).intValue(); - - List<PivotField> subPivots = null; - Map<String,FieldStatsInfo> fieldStatsInfos = null; - - if (4 <= nl.size()) { - for(int index = 3; index < nl.size(); index++) { - final String key = nl.getName(index); - final Object val = nl.getVal(index); - switch (key) { - - case "pivot": { - assert null != val : "Server sent back 'null' for sub pivots?"; - assert val instanceof List : "Server sent non-List for sub pivots?"; - - subPivots = readPivots( (List<NamedList>) val ); - break; - } - case "stats": { - assert null != val : "Server sent back 'null' for stats?"; - assert val instanceof NamedList : "Server sent non-NamedList for stats?"; - - fieldStatsInfos = extractFieldStatsInfo((NamedList<Object>) val); - break; - } - default: - throw new RuntimeException( "unknown key in pivot: "+ key+ " ["+val+"]"); - - } - } - } - - values.add( new PivotField( f, v, cnt, subPivots, fieldStatsInfos ) ); - } - return values; - } - - //------------------------------------------------------ - //------------------------------------------------------ - - /** - * Remove the field facet info - */ - public void removeFacets() { - _facetFields = new ArrayList<>(); - } - - //------------------------------------------------------ - //------------------------------------------------------ - - public NamedList<Object> getHeader() { - return _header; - } - - public SolrDocumentList getResults() { - return _results; - } - - public NamedList<ArrayList> getSortValues(){ - return _sortvalues; - } - - public Map<String, Object> getDebugMap() { - return _debugMap; - } - - public Map<String, String> getExplainMap() { - return _explainMap; - } - - public Map<String,Integer> getFacetQuery() { - return _facetQuery; - } - - public Map<String, SolrDocumentList> getExpandedResults(){ - return this._expandedResults; - } - - /** - * Returns the {@link GroupResponse} containing the group commands. - * A group command can be the result of one of the following parameters: - * <ul> - * <li>group.field - * <li>group.func - * <li>group.query - * </ul> - * - * @return the {@link GroupResponse} containing the group commands - */ - public GroupResponse getGroupResponse() { - return _groupResponse; - } - - public Map<String, Map<String, List<String>>> getHighlighting() { - return _highlighting; - } - - public SpellCheckResponse getSpellCheckResponse() { - return _spellResponse; - } - - public TermsResponse getTermsResponse() { - return _termsResponse; - } - - /** - * See also: {@link #getLimitingFacets()} - */ - public List<FacetField> getFacetFields() { - return _facetFields; - } - - public List<FacetField> getFacetDates() { - return _facetDates; - } - - public List<RangeFacet> getFacetRanges() { - return _facetRanges; - } - - public NamedList<List<PivotField>> getFacetPivot() { - return _facetPivot; - } - - public List<IntervalFacet> getIntervalFacets() { - return _intervalFacets; - } - - /** get - * - * @param name the name of the - * @return the FacetField by name or null if it does not exist - */ - public FacetField getFacetField(String name) { - if (_facetFields==null) return null; - for (FacetField f : _facetFields) { - if (f.getName().equals(name)) return f; - } - return null; - } - - public FacetField getFacetDate(String name) { - if (_facetDates == null) - return null; - for (FacetField f : _facetDates) - if (f.getName().equals(name)) - return f; - return null; - } - - /** - * @return a list of FacetFields where the count is less then - * then #getResults() {@link SolrDocumentList#getNumFound()} - * - * If you want all results exactly as returned by solr, use: - * {@link #getFacetFields()} - */ - public List<FacetField> getLimitingFacets() { - return _limitingFacets; - } - - public <T> List<T> getBeans(Class<T> type){ - return solrClient == null ? - new DocumentObjectBinder().getBeans(type,_results): - solrClient.getBinder().getBeans(type, _results); - } - - public Map<String, FieldStatsInfo> getFieldStatsInfo() { - return _fieldStatsInfo; - } - - public String getNextCursorMark() { - return _cursorMarkNext; - } -} - - -
