Merged searchapi (5.2.1) to 5.2.N (5.2.1)

130146 gjames: SEARCH-121: Implementing facet fields


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130305 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2016-09-06 15:39:32 +00:00
parent 7bb1ba047a
commit 9f5cc53cf3
7 changed files with 348 additions and 3 deletions

View File

@@ -0,0 +1,133 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.search.model;
import org.alfresco.service.cmr.search.SearchParameters.FieldFacetMethod;
import org.alfresco.service.cmr.search.SearchParameters.FieldFacetSort;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* POJO class representing the FacetField
*
* @author Gethin James
*/
public class FacetField
{
private final String field;
private final String label;
private final String prefix;
private final String sort; //actually an enum
private final String method; //actually an enum
private final Boolean missing;
private final Integer limit;
private final Integer offset;
private final Integer mincount;
private final Integer facetEnumCacheMinDf;
@JsonCreator
public FacetField(@JsonProperty("field") String field,
@JsonProperty("label") String label,
@JsonProperty("prefix") String prefix,
@JsonProperty("sort") String sort,
@JsonProperty("method") String method,
@JsonProperty("missing") Boolean missing,
@JsonProperty("limit") Integer limit,
@JsonProperty("offset") Integer offset,
@JsonProperty("mincount") Integer mincount,
@JsonProperty("facetEnumCacheMinDf") Integer facetEnumCacheMinDf)
{
this.field = field;
this.label = label;
this.prefix = prefix;
this.sort = sort;
this.method = method;
this.missing = missing == null?true:missing; //Not set in SolrQueryHTTPClient, bug?
this.limit = limit; //Can be null
this.offset = offset == null?0:offset;
this.mincount = mincount == null?0:mincount;
this.facetEnumCacheMinDf = facetEnumCacheMinDf == null?0:facetEnumCacheMinDf;
}
/**
"excludeFilters": [
"string"
],
"contains": "string",
"containsIgnoreCase": true,
**/
public String getField()
{
return field;
}
public String getLabel()
{
return label;
}
public String getPrefix()
{
return prefix;
}
public String getSort()
{
return sort;
}
public String getMethod()
{
return method;
}
public Boolean getMissing()
{
return missing;
}
public Integer getLimit()
{
return limit;
}
public Integer getOffset()
{
return offset;
}
public Integer getMincount()
{
return mincount;
}
public Integer getFacetEnumCacheMinDf()
{
return facetEnumCacheMinDf;
}
}

View File

@@ -0,0 +1,50 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.search.model;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
import java.util.List;
/**
* POJO class representing a FacetField
*/
public class FacetFields
{
private final List<FacetField> facets;
@JsonCreator
public FacetFields(@JsonProperty("facets") List<FacetField> facets)
{
this.facets = facets;
}
public List<FacetField> getFacets()
{
return facets;
}
}

View File

@@ -48,10 +48,11 @@ public class SearchQuery
private final Default defaults;
private final List<FilterQuery> filterQueries;
private final List<FacetQuery> facetQueries;
private final FacetFields facetFields;
private final Spelling spellcheck;
private final Scope scope;
public static final SearchQuery EMPTY = new SearchQuery(null, null, null, null, null,null, null, null, null, null);
public static final SearchQuery EMPTY = new SearchQuery(null, null, null, null, null,null, null, null, null, null, null);
@JsonCreator
public SearchQuery(@JsonProperty("query") Query query,
@@ -61,6 +62,7 @@ public class SearchQuery
@JsonProperty("templates") List<Template> templates,
@JsonProperty("defaults") Default defaults,
@JsonProperty("filterQueries") List<FilterQuery> filterQueries,
@JsonProperty("facetFields") FacetFields facetFields,
@JsonProperty("facetQueries") List<FacetQuery> facetQueries,
@JsonProperty("spellcheck") Spelling spellcheck,
@JsonProperty("scope") Scope scope)
@@ -75,6 +77,7 @@ public class SearchQuery
this.facetQueries = facetQueries;
this.spellcheck = spellcheck;
this.scope = scope;
this.facetFields = facetFields;
}
public Query getQuery()
@@ -124,4 +127,9 @@ public class SearchQuery
{
return scope;
}
public FacetFields getFacetFields()
{
return facetFields;
}
}