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

135972 gjames: SEARCH-339: Changed facet intervals to use the generic facets metric


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@136098 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2017-03-24 13:18:03 +00:00
parent 86a0ed3479
commit 4764a458a3
8 changed files with 279 additions and 36 deletions

View File

@@ -25,6 +25,7 @@
*/
package org.alfresco.rest.api.search.context;
import org.alfresco.rest.api.search.context.facetsresponse.GenericFacetResponse;
import org.alfresco.rest.api.search.model.SearchQuery;
import java.util.List;
@@ -38,10 +39,10 @@ public class SearchContext
private final List<FacetQueryContext> facetQueries;
private final SpellCheckContext spellCheck;
private final List<FacetFieldContext> facetsFields;
private final List<FacetFieldContext> facetIntervals;
private final List<GenericFacetResponse> facets;
private final SearchQuery request;
public SearchContext(long lastTxId, List<FacetQueryContext> facetQueries, List<FacetFieldContext> facetsFields, List<FacetFieldContext> facetIntervals, SpellCheckContext spellCheck,
public SearchContext(long lastTxId, List<GenericFacetResponse> facets, List<FacetQueryContext> facetQueries, List<FacetFieldContext> facetsFields, SpellCheckContext spellCheck,
SearchQuery request)
{
this.spellCheck = spellCheck;
@@ -56,7 +57,7 @@ public class SearchContext
}
this.facetQueries = facetQueries;
this.facetsFields = facetsFields;
this.facetIntervals = facetIntervals;
this.facets = facets;
}
public Consistency getConsistency()
@@ -74,9 +75,9 @@ public class SearchContext
return spellCheck;
}
public List<FacetFieldContext> getFacetIntervals()
public List<GenericFacetResponse> getFacets()
{
return facetIntervals;
return facets;
}
public List<FacetFieldContext> getFacetsFields()

View File

@@ -0,0 +1,69 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2017 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.context.facetsresponse;
import java.util.List;
/**
* A Generic Bucket response covering range, interval, pivot etc.
*/
public class GenericBucket
{
private final String label;
private final String filterQuery;
private final Object display;
private final List<Metric> metrics;
public GenericBucket(String label, String filterQuery, Object display, List<Metric> metrics)
{
this.label = label;
this.filterQuery = filterQuery;
this.display = display;
this.metrics = metrics;
}
public String getFilterQuery()
{
return filterQuery;
}
public Object getDisplay()
{
return display;
}
public String getLabel()
{
return label;
}
public List<Metric> getMetrics()
{
return metrics;
}
}

View File

@@ -0,0 +1,62 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2017 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.context.facetsresponse;
import java.util.List;
/**
* A Generic facet response covering range, interval, pivot etc.
*/
public class GenericFacetResponse
{
public static enum FACET_TYPE {range, interval};
private final FACET_TYPE type;
private final String label;
private final List<GenericBucket> buckets;
public GenericFacetResponse(FACET_TYPE type, String label, List<GenericBucket> buckets)
{
this.type = type;
this.label = label;
this.buckets = buckets;
}
public String getLabel()
{
return label;
}
public List<GenericBucket> getBuckets()
{
return buckets;
}
public FACET_TYPE getType()
{
return type;
}
}

View File

@@ -0,0 +1,39 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2017 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.context.facetsresponse;
import java.util.Map;
import java.util.Date;
/**
* Metrics returned from Solr
*/
public interface Metric
{
public static enum METRIC_TYPE {count};
METRIC_TYPE getType();
Map<String, Object> getValue();
}

View File

@@ -0,0 +1,54 @@
/*-
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2017 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.context.facetsresponse;
import java.util.HashMap;
import java.util.Map;
/**
* A count metric
*/
public class MetricCount implements Metric
{
private final Map<String, Object> value = new HashMap<>(1);
public MetricCount(Integer count)
{
value.put("count", count);
}
@Override
public METRIC_TYPE getType()
{
return METRIC_TYPE.count;
}
@Override
public Map<String, Object> getValue()
{
return value;
}
}