mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
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:
@@ -28,6 +28,8 @@ package org.alfresco.rest.api.search.impl;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.rest.api.search.model.Default;
|
import org.alfresco.rest.api.search.model.Default;
|
||||||
|
import org.alfresco.rest.api.search.model.FacetField;
|
||||||
|
import org.alfresco.rest.api.search.model.FacetFields;
|
||||||
import org.alfresco.rest.api.search.model.FacetQuery;
|
import org.alfresco.rest.api.search.model.FacetQuery;
|
||||||
import org.alfresco.rest.api.search.model.FilterQuery;
|
import org.alfresco.rest.api.search.model.FilterQuery;
|
||||||
import org.alfresco.rest.api.search.model.Query;
|
import org.alfresco.rest.api.search.model.Query;
|
||||||
@@ -46,6 +48,9 @@ import org.alfresco.service.cmr.search.LimitBy;
|
|||||||
import org.alfresco.service.cmr.search.ResultSet;
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
import org.alfresco.rest.api.model.Node;
|
import org.alfresco.rest.api.model.Node;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters.FieldFacet;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters.FieldFacetMethod;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters.FieldFacetSort;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters.Operator;
|
import org.alfresco.service.cmr.search.SearchParameters.Operator;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters.SortDefinition;
|
import org.alfresco.service.cmr.search.SearchParameters.SortDefinition;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters.SortDefinition.SortType;
|
import org.alfresco.service.cmr.search.SearchParameters.SortDefinition.SortType;
|
||||||
@@ -104,6 +109,7 @@ public class SearchMapper
|
|||||||
fromDefault(sp, searchQuery.getDefaults());
|
fromDefault(sp, searchQuery.getDefaults());
|
||||||
fromFilterQuery(sp, searchQuery.getFilterQueries());
|
fromFilterQuery(sp, searchQuery.getFilterQueries());
|
||||||
fromFacetQuery(sp, searchQuery.getFacetQueries());
|
fromFacetQuery(sp, searchQuery.getFacetQueries());
|
||||||
|
fromFacetFields(sp, searchQuery.getFacetFields());
|
||||||
fromSpellCheck(sp, searchQuery.getSpellcheck());
|
fromSpellCheck(sp, searchQuery.getSpellcheck());
|
||||||
fromScope(sp, searchQuery.getScope());
|
fromScope(sp, searchQuery.getScope());
|
||||||
|
|
||||||
@@ -309,6 +315,65 @@ public class SearchMapper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SearchParameters from FacetFields object
|
||||||
|
* @param sp SearchParameters
|
||||||
|
* @param FacetFields facetFields
|
||||||
|
*/
|
||||||
|
public void fromFacetFields(SearchParameters sp, FacetFields facetFields)
|
||||||
|
{
|
||||||
|
if (facetFields != null)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("facetFields facets", facetFields.getFacets());
|
||||||
|
|
||||||
|
if (facetFields.getFacets() != null && !facetFields.getFacets().isEmpty())
|
||||||
|
{
|
||||||
|
for (FacetField facet : facetFields.getFacets())
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatoryString("facetFields facet field", facet.getField());
|
||||||
|
String field = facet.getField();
|
||||||
|
String label = facet.getLabel()!=null?facet.getLabel():field;
|
||||||
|
field = "{key='"+label+"'}"+field;
|
||||||
|
|
||||||
|
FieldFacet ff = new FieldFacet(field);
|
||||||
|
|
||||||
|
if (facet.getSort() != null && !facet.getSort().isEmpty())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ff.setSort(FieldFacetSort.valueOf(facet.getSort()));
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { facet.getSort() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (facet.getMethod() != null && !facet.getMethod().isEmpty())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ff.setMethod(FieldFacetMethod.valueOf(facet.getMethod()));
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID, new Object[] { facet.getMethod() });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ff.setPrefix(facet.getPrefix());
|
||||||
|
ff.setCountDocsMissingFacetField(facet.getMissing());
|
||||||
|
ff.setLimitOrNull(facet.getLimit());
|
||||||
|
ff.setOffset(facet.getOffset());
|
||||||
|
ff.setMinCount(facet.getMincount());
|
||||||
|
ff.setEnumMethodCacheMinDF(facet.getFacetEnumCacheMinDf());
|
||||||
|
|
||||||
|
sp.addFieldFacet(ff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* SearchParameters from SpellCheck object
|
* SearchParameters from SpellCheck object
|
||||||
* @param sp SearchParameters
|
* @param sp SearchParameters
|
||||||
|
133
source/java/org/alfresco/rest/api/search/model/FacetField.java
Normal file
133
source/java/org/alfresco/rest/api/search/model/FacetField.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
@@ -48,10 +48,11 @@ public class SearchQuery
|
|||||||
private final Default defaults;
|
private final Default defaults;
|
||||||
private final List<FilterQuery> filterQueries;
|
private final List<FilterQuery> filterQueries;
|
||||||
private final List<FacetQuery> facetQueries;
|
private final List<FacetQuery> facetQueries;
|
||||||
|
private final FacetFields facetFields;
|
||||||
private final Spelling spellcheck;
|
private final Spelling spellcheck;
|
||||||
private final Scope scope;
|
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
|
@JsonCreator
|
||||||
public SearchQuery(@JsonProperty("query") Query query,
|
public SearchQuery(@JsonProperty("query") Query query,
|
||||||
@@ -61,6 +62,7 @@ public class SearchQuery
|
|||||||
@JsonProperty("templates") List<Template> templates,
|
@JsonProperty("templates") List<Template> templates,
|
||||||
@JsonProperty("defaults") Default defaults,
|
@JsonProperty("defaults") Default defaults,
|
||||||
@JsonProperty("filterQueries") List<FilterQuery> filterQueries,
|
@JsonProperty("filterQueries") List<FilterQuery> filterQueries,
|
||||||
|
@JsonProperty("facetFields") FacetFields facetFields,
|
||||||
@JsonProperty("facetQueries") List<FacetQuery> facetQueries,
|
@JsonProperty("facetQueries") List<FacetQuery> facetQueries,
|
||||||
@JsonProperty("spellcheck") Spelling spellcheck,
|
@JsonProperty("spellcheck") Spelling spellcheck,
|
||||||
@JsonProperty("scope") Scope scope)
|
@JsonProperty("scope") Scope scope)
|
||||||
@@ -75,6 +77,7 @@ public class SearchQuery
|
|||||||
this.facetQueries = facetQueries;
|
this.facetQueries = facetQueries;
|
||||||
this.spellcheck = spellcheck;
|
this.spellcheck = spellcheck;
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
|
this.facetFields = facetFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query getQuery()
|
public Query getQuery()
|
||||||
@@ -124,4 +127,9 @@ public class SearchQuery
|
|||||||
{
|
{
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FacetFields getFacetFields()
|
||||||
|
{
|
||||||
|
return facetFields;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,8 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import org.alfresco.rest.api.search.impl.SearchMapper;
|
import org.alfresco.rest.api.search.impl.SearchMapper;
|
||||||
import org.alfresco.rest.api.search.model.Default;
|
import org.alfresco.rest.api.search.model.Default;
|
||||||
|
import org.alfresco.rest.api.search.model.FacetField;
|
||||||
|
import org.alfresco.rest.api.search.model.FacetFields;
|
||||||
import org.alfresco.rest.api.search.model.FacetQuery;
|
import org.alfresco.rest.api.search.model.FacetQuery;
|
||||||
import org.alfresco.rest.api.search.model.FilterQuery;
|
import org.alfresco.rest.api.search.model.FilterQuery;
|
||||||
import org.alfresco.rest.api.search.model.Query;
|
import org.alfresco.rest.api.search.model.Query;
|
||||||
@@ -51,7 +53,9 @@ import org.alfresco.rest.framework.resource.parameters.Paging;
|
|||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.LimitBy;
|
import org.alfresco.service.cmr.search.LimitBy;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters.FieldFacet;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
import org.codehaus.jackson.annotate.JsonProperty;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -396,11 +400,84 @@ public class SearchMapperTests
|
|||||||
assertEquals("deleted://SpacesStore",searchParameters.getStores().get(1).toString());
|
assertEquals("deleted://SpacesStore",searchParameters.getStores().get(1).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fromFacetFields() throws Exception
|
||||||
|
{
|
||||||
|
SearchParameters searchParameters = new SearchParameters();
|
||||||
|
//Doesn't error
|
||||||
|
searchMapper.fromFacetFields(searchParameters, null);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(null));
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae)
|
||||||
|
{
|
||||||
|
assertTrue(iae.getLocalizedMessage().contains("facetFields facets is a mandatory parameter"));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(Arrays.asList(new FacetField(null,null,null,null,null,null,null,null,null,null))));
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae)
|
||||||
|
{
|
||||||
|
assertTrue(iae.getLocalizedMessage().contains("facetFields facet field is a mandatory parameter"));
|
||||||
|
}
|
||||||
|
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(Arrays.asList(new FacetField("myfield",null,null,null,null,null,null,null,null,null))));
|
||||||
|
assertEquals(1 ,searchParameters.getFieldFacets().size());
|
||||||
|
FieldFacet ff = searchParameters.getFieldFacets().get(0);
|
||||||
|
|
||||||
|
//Check defaults
|
||||||
|
//assertEquals(true, ff.getMissing());
|
||||||
|
assertNull(ff.getLimitOrNull());
|
||||||
|
assertEquals(0, ff.getOffset());
|
||||||
|
assertEquals(0, ff.getMinCount());
|
||||||
|
assertEquals(0, ff.getEnumMethodCacheMinDF());
|
||||||
|
|
||||||
|
assertEquals("{key='myfield'}myfield" ,ff.getField());
|
||||||
|
|
||||||
|
searchParameters = new SearchParameters();
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(Arrays.asList(new FacetField("myfield","mylabel","myprefix",null,null,null,null,null,null,null))));
|
||||||
|
|
||||||
|
ff = searchParameters.getFieldFacets().get(0);
|
||||||
|
assertEquals("{key='mylabel'}myfield" ,ff.getField());
|
||||||
|
assertEquals("myprefix" ,ff.getPrefix());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(Arrays.asList(new FacetField("myfield",null,null,"badsort",null,null,null,null,null,null))));
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (InvalidArgumentException iae)
|
||||||
|
{
|
||||||
|
//Sort is an enum
|
||||||
|
assertNotNull(iae);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(Arrays.asList(new FacetField("myfield",null,null, null,"badmethod",null,null,null,null,null))));
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
catch (InvalidArgumentException iae)
|
||||||
|
{
|
||||||
|
//Method is an enum
|
||||||
|
assertNotNull(iae);
|
||||||
|
}
|
||||||
|
|
||||||
|
searchParameters = new SearchParameters();
|
||||||
|
searchMapper.fromFacetFields(searchParameters, new FacetFields(Arrays.asList(new FacetField("myfield",null,null,"INDEX","ENUM",null,null,null,null,null))));
|
||||||
|
ff = searchParameters.getFieldFacets().get(0);
|
||||||
|
assertEquals("INDEX" ,ff.getSort().toString());
|
||||||
|
assertEquals("ENUM" ,ff.getMethod().toString());
|
||||||
|
}
|
||||||
|
|
||||||
private SearchQuery minimalQuery()
|
private SearchQuery minimalQuery()
|
||||||
{
|
{
|
||||||
Query query = new Query("cmis", "foo", "");
|
Query query = new Query("cmis", "foo", "");
|
||||||
SearchQuery sq = new SearchQuery(query,null, null, null, null, null, null, null, null, null);
|
SearchQuery sq = new SearchQuery(query,null, null, null, null, null, null, null, null, null, null);
|
||||||
return sq;
|
return sq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.alfresco.rest.api.search.context.SpellCheckContext;
|
import org.alfresco.rest.api.search.context.SpellCheckContext;
|
||||||
import org.alfresco.rest.api.search.model.Default;
|
import org.alfresco.rest.api.search.model.Default;
|
||||||
|
import org.alfresco.rest.api.search.model.FacetField;
|
||||||
import org.alfresco.rest.api.search.model.SearchQuery;
|
import org.alfresco.rest.api.search.model.SearchQuery;
|
||||||
import org.alfresco.rest.framework.jacksonextensions.ExecutionResult;
|
import org.alfresco.rest.framework.jacksonextensions.ExecutionResult;
|
||||||
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
|
||||||
@@ -90,7 +91,17 @@ public class SearchQuerySerializerTests
|
|||||||
assertEquals("alfrezco", searchQuery.getSpellcheck().getQuery());
|
assertEquals("alfrezco", searchQuery.getSpellcheck().getQuery());
|
||||||
assertEquals(1, searchQuery.getScope().getStores().size());
|
assertEquals(1, searchQuery.getScope().getStores().size());
|
||||||
assertEquals("test://SpacesStore", searchQuery.getScope().getStores().get(0));
|
assertEquals("test://SpacesStore", searchQuery.getScope().getStores().get(0));
|
||||||
|
assertEquals(2, searchQuery.getFacetFields().getFacets().size());
|
||||||
|
FacetField ff = searchQuery.getFacetFields().getFacets().get(0);
|
||||||
|
assertEquals("aField", ff.getField());
|
||||||
|
assertEquals("myquery2", ff.getPrefix());
|
||||||
|
assertEquals("COUNT", ff.getSort());
|
||||||
|
assertEquals(false, ff.getMissing());
|
||||||
|
ff = searchQuery.getFacetFields().getFacets().get(1);
|
||||||
|
assertEquals("anotherField", ff.getField());
|
||||||
|
assertEquals("mylabel", ff.getLabel());
|
||||||
|
assertEquals("FC", ff.getMethod());
|
||||||
|
assertEquals(Integer.valueOf(5), ff.getMincount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -60,6 +60,7 @@ public class SerializerTestHelper implements RequestReader
|
|||||||
+ "\"templates\": [{\"name\": \"mytemp\",\"template\": \"ATEMP\"}, {\"name\": \"yourtemp\",\"template\": \"%cm:content\"}],"
|
+ "\"templates\": [{\"name\": \"mytemp\",\"template\": \"ATEMP\"}, {\"name\": \"yourtemp\",\"template\": \"%cm:content\"}],"
|
||||||
+ "\"defaults\": {\"namespace\": \"namesp\",\"defaultFieldName\": \"myfield\",\"defaultFTSOperator\": \"AND\", \"textAttributes\": [\"roy\", \"king\"]},"
|
+ "\"defaults\": {\"namespace\": \"namesp\",\"defaultFieldName\": \"myfield\",\"defaultFTSOperator\": \"AND\", \"textAttributes\": [\"roy\", \"king\"]},"
|
||||||
+ "\"filterQueries\": [{\"query\": \"myquery\",\"tags\": [\"tag1\", \"tag2\"]},{\"query\": \"myquery2\"}],"
|
+ "\"filterQueries\": [{\"query\": \"myquery\",\"tags\": [\"tag1\", \"tag2\"]},{\"query\": \"myquery2\"}],"
|
||||||
|
+ "\"facetFields\": {\"facets\": [{\"field\": \"aField\",\"prefix\": \"myquery2\",\"sort\": \"COUNT\",\"missing\": \"false\"}, {\"field\": \"anotherField\",\"label\": \"mylabel\",\"method\": \"FC\",\"mincount\": \"5\"}]},"
|
||||||
+ "\"facetQueries\": [{\"query\": \"facquery\",\"label\": \"facnoused\"}],"
|
+ "\"facetQueries\": [{\"query\": \"facquery\",\"label\": \"facnoused\"}],"
|
||||||
+ "\"spellcheck\": {\"query\": \"alfrezco\"},"
|
+ "\"spellcheck\": {\"query\": \"alfrezco\"},"
|
||||||
+ "\"scope\": { \"stores\": [\"test://SpacesStore\"]},"
|
+ "\"scope\": { \"stores\": [\"test://SpacesStore\"]},"
|
||||||
|
Reference in New Issue
Block a user