diff --git a/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java b/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java index 06e7d8d09..5f4c15b1f 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java @@ -76,7 +76,9 @@ public class NodeClientFactoryBean implements FactoryBean, Initializ nodeClient = (NodeClient) nodeBuilder().settings(Settings.builder().put(loadConfig()) .put("http.enabled", String.valueOf(this.enableHttp)) .put("path.home", this.pathHome) - .put("path.data", this.pathData)) + .put("path.data", this.pathData) + .put("script.inline", "on") + ) .clusterName(this.clusterName).local(this.local).node() .client(); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java b/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java index 30bc87fd4..0add0f2c9 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java @@ -35,6 +35,8 @@ import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHitField; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.data.elasticsearch.ElasticsearchException; import org.springframework.data.elasticsearch.annotations.Document; @@ -72,7 +74,7 @@ public class DefaultResultMapper extends AbstractResultMapper { } @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { long totalHits = response.getHits().totalHits(); List results = new ArrayList(); for (SearchHit hit : response.getHits()) { @@ -88,17 +90,7 @@ public class DefaultResultMapper extends AbstractResultMapper { results.add(result); } } - //TODO: ako facets !!! -/* List facets = new ArrayList(); - if (response.getFacets() != null) { - for (Facet facet : response.getFacets()) { - FacetResult facetResult = DefaultFacetMapper.parse(facet); - if (facetResult != null) { - facets.add(facetResult); - } - } - }*/ - return new FacetedPageImpl(results, pageable, totalHits, null ); + return new PageImpl(results, pageable, totalHits); } private void populateScriptFields(T result, SearchHit hit) { diff --git a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchOperations.java b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchOperations.java index cd2f00656..a37ab2d1e 100755 --- a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchOperations.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchOperations.java @@ -173,7 +173,7 @@ public interface ElasticsearchOperations { * @param clazz * @return */ - FacetedPage queryForPage(SearchQuery query, Class clazz); + Page queryForPage(SearchQuery query, Class clazz); /** * Execute the query against elasticsearch and return result as {@link Page} using custom mapper @@ -182,7 +182,7 @@ public interface ElasticsearchOperations { * @param clazz * @return */ - FacetedPage queryForPage(SearchQuery query, Class clazz, SearchResultMapper mapper); + Page queryForPage(SearchQuery query, Class clazz, SearchResultMapper mapper); /** * Execute the query against elasticsearch and return result as {@link Page} @@ -200,7 +200,7 @@ public interface ElasticsearchOperations { * @param clazz * @return */ - FacetedPage queryForPage(StringQuery query, Class clazz); + Page queryForPage(StringQuery query, Class clazz); /** * Execute the query against elasticsearch and return result as {@link Page} using custom mapper @@ -209,7 +209,7 @@ public interface ElasticsearchOperations { * @param clazz * @return */ - FacetedPage queryForPage(StringQuery query, Class clazz, SearchResultMapper mapper); + Page queryForPage(StringQuery query, Class clazz, SearchResultMapper mapper); /** * Executes the given {@link CriteriaQuery} against elasticsearch and return result as {@link CloseableIterator}. @@ -431,15 +431,6 @@ public interface ElasticsearchOperations { */ boolean deleteIndex(String indexName); - /** - * Deletes a type in an index - * - * @param index - * @param type - */ - //TODo: ako remove this - /*void deleteType(String index, String type);*/ - /** * check if index is exists * diff --git a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java index 00bd94789..74229576a 100755 --- a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java @@ -76,10 +76,7 @@ import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.core.io.ClassPathResource; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; +import org.springframework.data.domain.*; import org.springframework.data.elasticsearch.ElasticsearchException; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Mapping; @@ -259,12 +256,12 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati } @Override - public FacetedPage queryForPage(SearchQuery query, Class clazz) { + public Page queryForPage(SearchQuery query, Class clazz) { return queryForPage(query, clazz, resultsMapper); } @Override - public FacetedPage queryForPage(SearchQuery query, Class clazz, SearchResultMapper mapper) { + public Page queryForPage(SearchQuery query, Class clazz, SearchResultMapper mapper) { SearchResponse response = doSearch(prepareSearch(query, clazz), query); return mapper.mapResults(response, clazz, query.getPageable()); } @@ -328,12 +325,12 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati } @Override - public FacetedPage queryForPage(StringQuery query, Class clazz) { + public Page queryForPage(StringQuery query, Class clazz) { return queryForPage(query, clazz, resultsMapper); } @Override - public FacetedPage queryForPage(StringQuery query, Class clazz, SearchResultMapper mapper) { + public Page queryForPage(StringQuery query, Class clazz, SearchResultMapper mapper) { SearchResponse response = getSearchResponse(prepareSearch(query, clazz).setQuery(query.getSource()).execute()); return mapper.mapResults(response, clazz, query.getPageable()); } @@ -668,7 +665,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati while (hasRecords) { Page page = scroll(scrollId, 5000, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List result = new ArrayList(); for (SearchHit searchHit : response.getHits()) { String id = searchHit.getId(); @@ -676,7 +673,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati } if (result.size() > 0) { - return new FacetedPageImpl((List) result); + return new PageImpl((List) result); } return null; } @@ -864,18 +861,6 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati } } -/* - if (CollectionUtils.isNotEmpty(searchQuery.getFacets())) { - for (FacetRequest facetRequest : searchQuery.getFacets()) { - FacetBuilder facet = facetRequest.getFacet(); - if (facetRequest.applyQueryFilter() && searchQuery.getFilter() != null) { - facet.facetFilter(searchQuery.getFilter()); - } - searchRequest.addFacet(facet); - } - } -*/ - if (searchQuery.getHighlightFields() != null) { for (HighlightBuilder.Field highlightField : searchQuery.getHighlightFields()) { searchRequest.addHighlightedField(highlightField); diff --git a/src/main/java/org/springframework/data/elasticsearch/core/FacetedPage.java b/src/main/java/org/springframework/data/elasticsearch/core/FacetedPage.java deleted file mode 100644 index af4164cfa..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/FacetedPage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core; - -import java.util.List; - -import org.springframework.data.domain.Page; -import org.springframework.data.elasticsearch.core.facet.FacetResult; - -/** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public interface FacetedPage extends Page { - - boolean hasFacets(); - - List getFacets(); - - FacetResult getFacet(String name); -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java b/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java deleted file mode 100644 index bd8d58492..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/FacetedPageImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.collections.CollectionUtils; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.facet.FacetResult; - -/** - * Container for query result and facet results - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public class FacetedPageImpl extends PageImpl implements FacetedPage { - - private List facets; - private Map mapOfFacets = new HashMap(); - - public FacetedPageImpl(List content) { - super(content); - } - - public FacetedPageImpl(List content, Pageable pageable, long total) { - super(content, pageable, total); - } - - public FacetedPageImpl(List content, Pageable pageable, long total, List facets) { - super(content, pageable, total); - this.facets = facets; - if(facets!=null) { - for (FacetResult facet : facets) { - mapOfFacets.put(facet.getName(), facet); - } - } - } - - @Override - public boolean hasFacets() { - return CollectionUtils.isNotEmpty(facets); - } - - @Override - public List getFacets() { - return facets; - } - - @Override - public FacetResult getFacet(String name) { - return mapOfFacets.get(name); - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/SearchResultMapper.java b/src/main/java/org/springframework/data/elasticsearch/core/SearchResultMapper.java index d93d90ba1..e35e0c99f 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/SearchResultMapper.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/SearchResultMapper.java @@ -16,6 +16,7 @@ package org.springframework.data.elasticsearch.core; import org.elasticsearch.action.search.SearchResponse; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; /** @@ -23,5 +24,5 @@ import org.springframework.data.domain.Pageable; */ public interface SearchResultMapper { - FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable); + Page mapResults(SearchResponse response, Class clazz, Pageable pageable); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/AbstractFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/AbstractFacetRequest.java deleted file mode 100644 index 99256de25..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/AbstractFacetRequest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet; - -import org.springframework.util.Assert; - -*/ -/** - * @author Artur Konczak - *//* - -public abstract class AbstractFacetRequest implements FacetRequest { - - private String name; - private boolean applyQueryFilter; - - public AbstractFacetRequest(String name) { - Assert.hasText(name, "Facet can't be null or empty !!!"); - this.name = name; - } - - protected String getName() { - return name; - } - - public void setApplyQueryFilter(boolean applyQueryFilter) { - this.applyQueryFilter = applyQueryFilter; - } - - @Override - public boolean applyQueryFilter() { - return applyQueryFilter; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/AbstractFacetResult.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/AbstractFacetResult.java deleted file mode 100644 index 02294d508..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/AbstractFacetResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet; - -import org.springframework.util.Assert; - -/** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public class AbstractFacetResult implements FacetResult { - - private final String name; - private final FacetType type; - - protected AbstractFacetResult(String name, FacetType type) { - Assert.hasText(name, "Facet name can't be null and should have a value"); - this.name = name; - this.type = type; - } - - @Override - public String getName() { - return name; - } - - @Override - public FacetType getType() { - return type; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/DefaultFacetMapper.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/DefaultFacetMapper.java deleted file mode 100644 index 0195e02b1..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/DefaultFacetMapper.java +++ /dev/null @@ -1,81 +0,0 @@ -///* -// * Copyright 2014 the original author or authors. -// * -// * Licensed 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.springframework.data.elasticsearch.core.facet; -// -//import java.util.ArrayList; -//import java.util.List; -// -//import org.elasticsearch.search.facet.Facet; -//import org.elasticsearch.search.facet.histogram.HistogramFacet; -//import org.elasticsearch.search.facet.range.RangeFacet; -//import org.elasticsearch.search.facet.statistical.StatisticalFacet; -//import org.elasticsearch.search.facet.terms.TermsFacet; -//import org.springframework.data.elasticsearch.core.facet.result.*; -// -///** -// * @author Artur Konczak -// * @author Petar Tahchiev -// */ -//public class DefaultFacetMapper { -// -// public static FacetResult parse(Facet facet) { -// if (facet instanceof TermsFacet) { -// return parseTerm((TermsFacet) facet); -// } -// -// if (facet instanceof RangeFacet) { -// return parseRange((RangeFacet) facet); -// } -// -// if (facet instanceof StatisticalFacet) { -// return parseStatistical((StatisticalFacet) facet); -// } -// -// if (facet instanceof HistogramFacet) { -// return parseHistogram((HistogramFacet) facet); -// } -// -// return null; -// } -// -// private static FacetResult parseTerm(TermsFacet facet) { -// List entries = new ArrayList(); -// for (TermsFacet.Entry entry : facet.getEntries()) { -// entries.add(new Term(entry.getTerm().toString(), entry.getCount())); -// } -// return new TermResult(facet.getName(), entries, facet.getTotalCount(), facet.getOtherCount(), facet.getMissingCount()); -// } -// -// private static FacetResult parseRange(RangeFacet facet) { -// List entries = new ArrayList(); -// for (RangeFacet.Entry entry : facet.getEntries()) { -// entries.add(new Range(entry.getFrom() == Double.NEGATIVE_INFINITY ? null : entry.getFrom(), entry.getTo() == Double.POSITIVE_INFINITY ? null : entry.getTo(), entry.getCount(), entry.getTotal(), entry.getTotalCount(), entry.getMin(), entry.getMax())); -// } -// return new RangeResult(facet.getName(), entries); -// } -// -// private static FacetResult parseStatistical(StatisticalFacet facet) { -// return new StatisticalResult(facet.getName(), facet.getCount(), facet.getMax(), facet.getMin(), facet.getMean(), facet.getStdDeviation(), facet.getSumOfSquares(), facet.getTotal(), facet.getVariance()); -// } -// -// private static FacetResult parseHistogram(HistogramFacet facet) { -// List entries = new ArrayList(); -// for (HistogramFacet.Entry entry : facet.getEntries()) { -// entries.add(new IntervalUnit(entry.getKey(), entry.getCount(), entry.getTotalCount(), entry.getTotal(), entry.getMean(), entry.getMin(), entry.getMax())); -// } -// return new HistogramResult(facet.getName(), entries); -// } -//} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetRequest.java deleted file mode 100644 index 2a7120cfc..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetRequest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet; - -import org.elasticsearch.search.facet.FacetBuilder; - -*/ -/** - * @author Artur Koczak - *//* - -public interface FacetRequest { - - public static final String FIELD_UNTOUCHED = "untouched"; - public static final String FIELD_SORT = "sort"; - - FacetBuilder getFacet(); - - boolean applyQueryFilter(); -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetResult.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetResult.java deleted file mode 100644 index eac98b010..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetResult.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet; - -/** - * Generic interface for all facets - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public interface FacetResult { - - String getName(); - - FacetType getType(); -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetType.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetType.java deleted file mode 100644 index c913ee107..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/FacetType.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet; - -/** - * @author Artur Konczak - * @author Petar Tahchiev - */ -public enum FacetType { - - term, range, histogram, statistical - -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java deleted file mode 100644 index b6862b0bf..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import java.util.concurrent.TimeUnit; - -import org.apache.commons.lang.StringUtils; -import org.elasticsearch.search.facet.FacetBuilder; -import org.elasticsearch.search.facet.FacetBuilders; -import org.elasticsearch.search.facet.histogram.HistogramFacetBuilder; -import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest; -import org.springframework.util.Assert; - -*/ -/** - * @author Artur Konczak - * @author Mohsin Husen - *//* - -public class HistogramFacetRequest extends AbstractFacetRequest { - - private String field; - private long interval; - private TimeUnit timeUnit; - - public HistogramFacetRequest(String name) { - super(name); - } - - public void setField(String field) { - this.field = field; - } - - public void setInterval(long interval) { - this.interval = interval; - } - - public void setTimeUnit(TimeUnit timeUnit) { - this.timeUnit = timeUnit; - } - - public FacetBuilder getFacet() { - Assert.notNull(getName(), "Facet name can't be a null !!!"); - Assert.isTrue(StringUtils.isNotBlank(field), "Please select field on which to build the facet !!!"); - Assert.isTrue(interval > 0, "Please provide interval as positive value greater them zero !!!"); - - HistogramFacetBuilder builder = FacetBuilders.histogramFacet(getName()); - builder.field(field); - - if (timeUnit != null) { - builder.interval(interval, timeUnit); - } else { - builder.interval(interval); - } - - return builder; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequestBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequestBuilder.java deleted file mode 100644 index a292c27e6..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequestBuilder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import java.util.concurrent.TimeUnit; - -import org.springframework.data.elasticsearch.core.facet.FacetRequest; - -*/ -/** - * @author Artur Konczak - *//* - -public class HistogramFacetRequestBuilder { - - HistogramFacetRequest result; - - public HistogramFacetRequestBuilder(String name) { - result = new HistogramFacetRequest(name); - } - - public HistogramFacetRequestBuilder field(String field) { - result.setField(field); - return this; - } - - public HistogramFacetRequestBuilder interval(long interval) { - result.setInterval(interval); - return this; - } - - public HistogramFacetRequestBuilder timeUnit(TimeUnit timeUnit) { - result.setTimeUnit(timeUnit); - return this; - } - - public FacetRequest build() { - return result; - } - - public HistogramFacetRequestBuilder applyQueryFilter() { - result.setApplyQueryFilter(true); - return this; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/NativeFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/NativeFacetRequest.java deleted file mode 100644 index 542815ced..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/NativeFacetRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import org.elasticsearch.search.facet.FacetBuilder; -import org.springframework.data.elasticsearch.core.facet.FacetRequest; - -*/ -/** - * @author Artur Konczak - * @author Mohsin Husen - *//* - -public class NativeFacetRequest implements FacetRequest { - - private FacetBuilder facet; - private boolean applyQueryFilter; - - public NativeFacetRequest(FacetBuilder facet) { - this(facet, false); - } - - public NativeFacetRequest(FacetBuilder facet, boolean applyQueryFilter) { - this.facet = facet; - this.applyQueryFilter = applyQueryFilter; - } - - @Override - public FacetBuilder getFacet() { - return facet; - } - - @Override - public boolean applyQueryFilter() { - return applyQueryFilter; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java deleted file mode 100644 index 179fb7416..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.elasticsearch.search.facet.FacetBuilder; -import org.elasticsearch.search.facet.FacetBuilders; -import org.elasticsearch.search.facet.range.RangeFacetBuilder; -import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest; -import org.springframework.util.Assert; - -*/ -/** - * Range facet for numeric fields - * - * @author Artur Konczak - * @author Akos Bordas - *//* - -public class RangeFacetRequest extends AbstractFacetRequest { - - private String field; - private String keyField; - private String valueField; - - private List entries = new ArrayList(); - - public RangeFacetRequest(String name) { - super(name); - } - - public void setField(String field) { - this.field = field; - } - - public void setFields(String keyField, String valueField) { - this.keyField = keyField; - this.valueField = valueField; - } - - public void range(Double from, Double to) { - entries.add(new DoubleEntry(from, to)); - } - - public void range(String from, String to) { - entries.add(new StringEntry(from, to)); - } - - public void addRange(Double from, Double to) { - entries.add(new DoubleEntry(from, to)); - } - - public void addRange(String from, String to) { - entries.add(new StringEntry(from, to)); - } - - @Override - public FacetBuilder getFacet() { - Assert.notNull(getName(), "Facet name can't be a null !!!"); - Assert.isTrue(StringUtils.isNotBlank(field) || StringUtils.isNotBlank(keyField) && StringUtils.isNotBlank(valueField), "Please select field or key field and value field !!!"); - - RangeFacetBuilder builder = FacetBuilders.rangeFacet(getName()); - if (StringUtils.isNotBlank(keyField)) { - builder.keyField(keyField).valueField(valueField); - } else { - builder.field(field); - } - - for (Entry entry : entries) { - if (entry instanceof DoubleEntry) { - DoubleEntry doubleEntry = (DoubleEntry) entry; - builder.addRange(validateValue(doubleEntry.getFrom(), Double.NEGATIVE_INFINITY), validateValue(doubleEntry.getTo(), Double.POSITIVE_INFINITY)); - } else { - StringEntry stringEntry = (StringEntry) entry; - builder.addRange(stringEntry.getFrom(), stringEntry.getTo()); - } - } - - return builder; - } - - private double validateValue(Double value, double defaultValue) { - return value == null ? defaultValue : value; - } - - static class DoubleEntry extends Entry { - - DoubleEntry(Double from, Double to) { - super(from, to); - } - } - - static class StringEntry extends Entry { - - StringEntry(String from, String to) { - super(from, to); - } - } - - static class Entry { - - T from; - T to; - - Entry(T from, T to) { - this.from = from; - this.to = to; - } - - public T getFrom() { - return from; - } - - public T getTo() { - return to; - } - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequestBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequestBuilder.java deleted file mode 100644 index 99d8d8823..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequestBuilder.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import org.springframework.data.elasticsearch.core.facet.FacetRequest; - -*/ -/** - * Basic range facet - * - * @author Artur Konczak - *//* - -public class RangeFacetRequestBuilder { - - RangeFacetRequest result; - - public RangeFacetRequestBuilder(String name) { - result = new RangeFacetRequest(name); - } - - public RangeFacetRequestBuilder field(String field) { - result.setField(field); - return this; - } - - public RangeFacetRequestBuilder fields(String keyField, String valueField) { - result.setFields(keyField, valueField); - return this; - } - - - public RangeFacetRequestBuilder range(double from, double to) { - result.range(from, to); - return this; - } - - public RangeFacetRequestBuilder range(String from, String to) { - result.range(from, to); - return this; - } - - public RangeFacetRequestBuilder from(double from) { - result.range(from, null); - return this; - } - - public RangeFacetRequestBuilder to(double to) { - result.range(null, to); - return this; - } - - public RangeFacetRequestBuilder from(String from) { - result.range(from, null); - return this; - } - - public RangeFacetRequestBuilder to(String to) { - result.range(null, to); - return this; - } - - public RangeFacetRequestBuilder applyQueryFilter() { - result.setApplyQueryFilter(true); - return this; - } - - public FacetRequest build() { - return result; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java deleted file mode 100644 index 353da2329..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.elasticsearch.search.facet.FacetBuilder; -import org.elasticsearch.search.facet.FacetBuilders; -import org.elasticsearch.search.facet.statistical.StatisticalFacetBuilder; -import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest; -import org.springframework.util.Assert; - -*/ -/** - * @author Petar Tahchiev - *//* - -public class StatisticalFacetRequest extends AbstractFacetRequest { - - private String field; - - private String[] fields; - - public StatisticalFacetRequest(String name) { - super(name); - } - - public void setField(String field) { - this.field = field; - } - - public void setFields(String... fields) { - this.fields = fields; - } - - public FacetBuilder getFacet() { - Assert.notNull(getName(), "Facet name can't be a null !!!"); - Assert.isTrue(StringUtils.isNotBlank(field) && fields == null, "Please select field or fields on which to build the facets !!!"); - - StatisticalFacetBuilder builder = FacetBuilders.statisticalFacet(getName()); - if (ArrayUtils.isNotEmpty(fields)) { - builder.fields(fields); - } else { - builder.field(field); - } - - return builder; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequestBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequestBuilder.java deleted file mode 100644 index a14562383..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequestBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import org.springframework.data.elasticsearch.core.facet.FacetRequest; - -*/ -/** - * @author Petar Tahchiev - *//* - -public class StatisticalFacetRequestBuilder { - - StatisticalFacetRequest result; - - public StatisticalFacetRequestBuilder(String name) { - result = new StatisticalFacetRequest(name); - } - - public StatisticalFacetRequestBuilder field(String field) { - result.setField(field); - return this; - } - - public StatisticalFacetRequestBuilder fields(String... fields) { - result.setFields(fields); - return this; - } - - public StatisticalFacetRequestBuilder applyQueryFilter() { - result.setApplyQueryFilter(true); - return this; - } - - public FacetRequest build() { - return result; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetOrder.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetOrder.java deleted file mode 100644 index deb7fd828..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetOrder.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -/** - * @author Artur Konczak - * @author Mohsin Husen - */ -public enum TermFacetOrder { - - ascTerm, descTerm, ascCount, descCount; - -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java deleted file mode 100644 index 74c01d062..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.elasticsearch.search.facet.FacetBuilder; -import org.elasticsearch.search.facet.FacetBuilders; -import org.elasticsearch.search.facet.terms.TermsFacet; -import org.elasticsearch.search.facet.terms.TermsFacetBuilder; -import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest; -import org.springframework.util.Assert; - -*/ -/** - * Term facet - * - * @author Artur Konczak - *//* - -public class TermFacetRequest extends AbstractFacetRequest { - - private String[] fields; - private Object[] excludeTerms; - private int size = 10; - private TermFacetOrder order = TermFacetOrder.descCount; - private boolean allTerms = false; - private String regex = null; - private int regexFlag = 0; - - public TermFacetRequest(String name) { - super(name); - } - - public void setFields(String... fields) { - this.fields = fields; - } - - public void setSize(int size) { - Assert.isTrue(size >= 0, "Size should be bigger then zero !!!"); - this.size = size; - } - - public void setOrder(TermFacetOrder order) { - this.order = order; - } - - public void setExcludeTerms(Object... excludeTerms) { - this.excludeTerms = excludeTerms; - } - - public void setAllTerms(boolean allTerms) { - this.allTerms = allTerms; - } - - public void setRegex(String regex) { - this.regex = regex; - } - - public void setRegex(String regex, int regexFlag) { - this.regex = regex; - this.regexFlag = regexFlag; - } - - @Override - public FacetBuilder getFacet() { - Assert.notEmpty(fields, "Please select at last one field !!!"); - TermsFacetBuilder builder = FacetBuilders.termsFacet(getName()).fields(fields).size(size); - switch (order) { - - case descTerm: - builder.order(TermsFacet.ComparatorType.REVERSE_TERM); - break; - case ascTerm: - builder.order(TermsFacet.ComparatorType.TERM); - break; - case ascCount: - builder.order(TermsFacet.ComparatorType.REVERSE_COUNT); - break; - default: - builder.order(TermsFacet.ComparatorType.COUNT); - } - if (ArrayUtils.isNotEmpty(excludeTerms)) { - builder.exclude(excludeTerms); - } - - if (allTerms) { - builder.allTerms(allTerms); - } - - if (StringUtils.isNotBlank(regex)) { - builder.regex(regex, regexFlag); - } - - return builder; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequestBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequestBuilder.java deleted file mode 100644 index b8a6e6d20..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequestBuilder.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.request; - -import org.springframework.data.elasticsearch.core.facet.FacetRequest; - -*/ -/** - * Basic term facet - * - * @author Artur Konczak - *//* - -public class TermFacetRequestBuilder { - - private TermFacetRequest result; - - public TermFacetRequestBuilder(String name) { - result = new TermFacetRequest(name); - } - - public TermFacetRequestBuilder fields(String... fields) { - result.setFields(fields); - return this; - } - - public TermFacetRequestBuilder size(int size) { - result.setSize(size); - return this; - } - - public TermFacetRequestBuilder excludeTerms(Object... terms) { - result.setExcludeTerms(terms); - return this; - } - - public TermFacetRequestBuilder allTerms() { - result.setAllTerms(true); - return this; - } - - public TermFacetRequestBuilder regex(String regex) { - result.setRegex(regex); - return this; - } - - public TermFacetRequestBuilder regex(String regex, int regexFlag) { - result.setRegex(regex, regexFlag); - return this; - } - - public TermFacetRequestBuilder ascTerm() { - result.setOrder(TermFacetOrder.ascTerm); - return this; - } - - public TermFacetRequestBuilder descTerm() { - result.setOrder(TermFacetOrder.descTerm); - return this; - } - - public TermFacetRequestBuilder ascCount() { - result.setOrder(TermFacetOrder.ascCount); - return this; - } - - public TermFacetRequestBuilder descCount() { - result.setOrder(TermFacetOrder.descCount); - return this; - } - - public TermFacetRequestBuilder applyQueryFilter() { - result.setApplyQueryFilter(true); - return this; - } - - public FacetRequest build() { - return result; - } -} -*/ diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/HistogramResult.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/HistogramResult.java deleted file mode 100644 index 4f1f3e653..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/HistogramResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -import java.util.List; - -import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult; -import org.springframework.data.elasticsearch.core.facet.FacetType; - -/** - * @author Artur Konczak - */ -public class HistogramResult extends AbstractFacetResult { - - private List terms; - - public HistogramResult(String name, List terms) { - super(name, FacetType.term); - this.terms = terms; - } - - public List getIntervalUnit() { - return terms; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/IntervalUnit.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/IntervalUnit.java deleted file mode 100644 index 99b1cfd0d..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/IntervalUnit.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Single term - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public class IntervalUnit { - - private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - - long key; - long count; - long totalCount; - double total; - double mean; - double min; - double max; - - public IntervalUnit(long key, long count, long totalCount, double total, double mean, double min, double max) { - this.key = key; - this.count = count; - this.totalCount = totalCount; - this.total = total; - this.mean = mean; - this.min = min; - this.max = max; - } - - public long getKey() { - return key; - } - - public long getCount() { - return count; - } - - public long getTotalCount() { - return totalCount; - } - - public double getTotal() { - return total; - } - - public double getMean() { - return mean; - } - - public double getMin() { - return min; - } - - public double getMax() { - return max; - } - - @Override - public String toString() { - return "IntervalUnit{" + - "key=" + format.format(new Date(key)) + - ", count=" + count + - ", totalCount=" + totalCount + - ", total=" + total + - ", mean=" + mean + - ", min=" + min + - ", max=" + max + - '}'; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/Range.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/Range.java deleted file mode 100644 index b7b3cd9fd..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/Range.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -/** - * Single range - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public class Range { - - private Double from; - private Double to; - private long count; - private double total; - private double totalCount; - private double min = Double.POSITIVE_INFINITY; - private double max = Double.NEGATIVE_INFINITY; - - public Range(Double from, Double to, long count, double total, double totalCount, double min, double max) { - this.from = from; - this.to = to; - this.count = count; - this.total = total; - this.totalCount = totalCount; - this.min = min; - this.max = max; - } - - public Double getFrom() { - return from; - } - - public Double getTo() { - return to; - } - - /** - * Return number of documents in range - * - * @return - */ - public long getCount() { - return count; - } - - public double getTotal() { - return total; - } - - public double getTotalCount() { - return totalCount; - } - - public double getMin() { - return min; - } - - public double getMax() { - return max; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/RangeResult.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/RangeResult.java deleted file mode 100644 index c9f3b8174..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/RangeResult.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -import java.util.List; - -import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult; -import org.springframework.data.elasticsearch.core.facet.FacetType; - -/** - * Basic term facet result - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public class RangeResult extends AbstractFacetResult { - - private List ranges; - - public RangeResult(String name, List ranges) { - super(name, FacetType.range); - this.ranges = ranges; - } - - public List getRanges() { - return ranges; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/StatisticalResult.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/StatisticalResult.java deleted file mode 100644 index 412315e98..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/StatisticalResult.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult; -import org.springframework.data.elasticsearch.core.facet.FacetType; - -/** - * @author Petar Tahchiev - */ -public class StatisticalResult extends AbstractFacetResult { - - private long count; - - private double max; - - private double min; - - private double mean; - - private double stdDeviation; - - private double sumOfSquares; - - private double total; - - private double variance; - - public StatisticalResult(String name, long count, double max, double min, double mean, double stdDeviation, double sumOfSquares, double total, double variance) { - super(name, FacetType.statistical); - this.count = count; - this.max = max; - this.min = min; - this.mean = mean; - this.stdDeviation = stdDeviation; - this.sumOfSquares = sumOfSquares; - this.total = total; - this.variance = variance; - } - - public long getCount() { - return count; - } - - public double getMax() { - return max; - } - - public double getMin() { - return min; - } - - public double getMean() { - return mean; - } - - public double getStdDeviation() { - return stdDeviation; - } - - public double getSumOfSquares() { - return sumOfSquares; - } - - public double getTotal() { - return total; - } - - public double getVariance() { - return variance; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/Term.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/Term.java deleted file mode 100644 index 9a355f1de..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/Term.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -/** - * Single term - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - */ -public class Term { - - private String term; - private int count; - - public Term(String term, int count) { - this.term = term; - this.count = count; - } - - public String getTerm() { - return term; - } - - public int getCount() { - return count; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/TermResult.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/result/TermResult.java deleted file mode 100644 index 8c152fce9..000000000 --- a/src/main/java/org/springframework/data/elasticsearch/core/facet/result/TermResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2014 the original author or authors. - * - * Licensed 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.springframework.data.elasticsearch.core.facet.result; - -import java.util.List; - -import org.springframework.data.elasticsearch.core.facet.AbstractFacetResult; -import org.springframework.data.elasticsearch.core.facet.FacetType; - -/** - * Basic term facet result - * - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - * @author Jonathan Yan - * @author Matija Obreza - */ -public class TermResult extends AbstractFacetResult { - - private List terms; - private long total; - private long other; - private long missing; - - public TermResult(String name, List terms, long total, long other, long missing) { - super(name, FacetType.term); - this.terms = terms; - this.total = total; - this.other = other; - this.missing = missing; - } - - public List getTerms() { - return terms; - } - - public long getTotal() { - return total; - } - - public long getOther() { - return other; - } - - public long getMissing() { - return missing; - } -} diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/ElasticsearchRepository.java b/src/main/java/org/springframework/data/elasticsearch/repository/ElasticsearchRepository.java index 7db1e3257..e2f5982d6 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/ElasticsearchRepository.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/ElasticsearchRepository.java @@ -20,7 +20,6 @@ import java.io.Serializable; import org.elasticsearch.index.query.QueryBuilder; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.core.FacetedPage; import org.springframework.data.elasticsearch.core.query.SearchQuery; import org.springframework.data.repository.NoRepositoryBean; @@ -37,9 +36,9 @@ public interface ElasticsearchRepository extends Ela Iterable search(QueryBuilder query); - FacetedPage search(QueryBuilder query, Pageable pageable); + Page search(QueryBuilder query, Pageable pageable); - FacetedPage search(SearchQuery searchQuery); + Page search(SearchQuery searchQuery); Page searchSimilar(T entity, String[] fields, Pageable pageable); } diff --git a/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java b/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java index a81e82db2..e63697c18 100644 --- a/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java +++ b/src/main/java/org/springframework/data/elasticsearch/repository/support/AbstractElasticsearchRepository.java @@ -21,7 +21,6 @@ import java.io.Serializable; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -32,7 +31,6 @@ import org.slf4j.LoggerFactory; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.domain.*; import org.springframework.data.elasticsearch.core.ElasticsearchOperations; -import org.springframework.data.elasticsearch.core.FacetedPage; import org.springframework.data.elasticsearch.core.query.*; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.util.Assert; @@ -192,13 +190,13 @@ public abstract class AbstractElasticsearchRepository search(QueryBuilder query, Pageable pageable) { + public Page search(QueryBuilder query, Pageable pageable) { SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(query).withPageable(pageable).build(); return elasticsearchOperations.queryForPage(searchQuery, getEntityClass()); } @Override - public FacetedPage search(SearchQuery query) { + public Page search(SearchQuery query) { return elasticsearchOperations.queryForPage(query, getEntityClass()); } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java b/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java index 02f9eb5bc..4a981d54a 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java @@ -20,6 +20,7 @@ import java.util.LinkedList; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetResponse; import org.elasticsearch.action.search.SearchResponse; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; /** @@ -46,7 +47,7 @@ public class CustomResultMapper implements ResultsMapper { } @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { return null; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/DefaultResultMapperTests.java b/src/test/java/org/springframework/data/elasticsearch/core/DefaultResultMapperTests.java index d475d0ac2..f46a801ca 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/DefaultResultMapperTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/DefaultResultMapperTests.java @@ -34,6 +34,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.springframework.data.domain.Page; import org.springframework.data.elasticsearch.entities.Car; /** @@ -63,7 +64,7 @@ public class DefaultResultMapperTests { when(response.getHits()).thenReturn(searchHits); //When - FacetedPage page = resultMapper.mapResults(response, Car.class, null); + Page page = resultMapper.mapResults(response, Car.class, null); //Then assertThat(page.hasContent(), is(true)); @@ -81,7 +82,7 @@ public class DefaultResultMapperTests { when(response.getHits()).thenReturn(searchHits); //When - FacetedPage page = resultMapper.mapResults(response, Car.class, null); + Page page = resultMapper.mapResults(response, Car.class, null); //Then assertThat(page.hasContent(), is(true)); diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java index 4f98d35ce..ec59b1068 100755 --- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java @@ -41,10 +41,7 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; +import org.springframework.data.domain.*; import org.springframework.data.elasticsearch.ElasticsearchException; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.core.query.*; @@ -490,7 +487,8 @@ public class ElasticsearchTemplateTests { // when SearchQuery searchQuery = new NativeSearchQueryBuilder() .withQuery(matchAllQuery()) - .withScriptField(new ScriptField("scriptedRate", new Script("doc['rate'].value * factor", ScriptService.ScriptType.INLINE, "groovy", params))) + .withScriptField(new ScriptField("scriptedRate", + new Script("doc['rate'].value * factor", ScriptService.ScriptType.INLINE, null , params))) .build(); Page sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class); // then @@ -521,7 +519,6 @@ public class ElasticsearchTemplateTests { @Test @Ignore("By default, the search request will fail if there is no mapping associated with a field. The ignore_unmapped option allows to ignore fields that have no mapping and not sort by them") public void shouldReturnSortedPageableResultsGivenStringQuery() { - // todo // given String documentId = randomNumeric(5); SampleEntity sampleEntity = new SampleEntity(); @@ -633,12 +630,12 @@ public class ElasticsearchTemplateTests { // when Page page = elasticsearchTemplate.queryForPage(searchQuery, String.class, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List values = new ArrayList(); for (SearchHit searchHit : response.getHits()) { values.add((String) searchHit.field("message").value()); } - return new FacetedPageImpl((List) values); + return new PageImpl((List) values); } }); // then @@ -763,7 +760,7 @@ public class ElasticsearchTemplateTests { while (hasRecords) { Page page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List result = new ArrayList(); for (SearchHit searchHit : response.getHits()) { String message = searchHit.getFields().get("message").getValue(); @@ -774,7 +771,7 @@ public class ElasticsearchTemplateTests { } if (result.size() > 0) { - return new FacetedPageImpl((List) result); + return new PageImpl((List) result); } return null; } @@ -814,7 +811,7 @@ public class ElasticsearchTemplateTests { while (hasRecords) { Page page = elasticsearchTemplate.scroll(scrollId, 10000L, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List result = new ArrayList(); for (SearchHit searchHit : response.getHits()) { String message = searchHit.getFields().get("message").getValue(); @@ -825,7 +822,7 @@ public class ElasticsearchTemplateTests { } if (result.size() > 0) { - return new FacetedPageImpl((List) result); + return new PageImpl((List) result); } return null; } @@ -862,7 +859,7 @@ public class ElasticsearchTemplateTests { while (hasRecords) { Page page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List chunk = new ArrayList(); for (SearchHit searchHit : response.getHits()) { if (response.getHits().getHits().length <= 0) { @@ -874,7 +871,7 @@ public class ElasticsearchTemplateTests { chunk.add(user); } if (chunk.size() > 0) { - return new FacetedPageImpl((List) chunk); + return new PageImpl((List) chunk); } return null; } @@ -906,7 +903,7 @@ public class ElasticsearchTemplateTests { while (hasRecords) { Page page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List chunk = new ArrayList(); for (SearchHit searchHit : response.getHits()) { if (response.getHits().getHits().length <= 0) { @@ -918,7 +915,7 @@ public class ElasticsearchTemplateTests { chunk.add(user); } if (chunk.size() > 0) { - return new FacetedPageImpl((List) chunk); + return new PageImpl((List) chunk); } return null; } @@ -1209,7 +1206,7 @@ public class ElasticsearchTemplateTests { Page sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List chunk = new ArrayList(); for (SearchHit searchHit : response.getHits()) { if (response.getHits().getHits().length <= 0) { @@ -1222,7 +1219,7 @@ public class ElasticsearchTemplateTests { chunk.add(user); } if (chunk.size() > 0) { - return new FacetedPageImpl((List) chunk); + return new PageImpl((List) chunk); } return null; } @@ -1275,7 +1272,7 @@ public class ElasticsearchTemplateTests { // then Page page = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List values = new ArrayList(); for (SearchHit searchHit : response.getHits()) { SampleEntity sampleEntity = new SampleEntity(); @@ -1283,7 +1280,7 @@ public class ElasticsearchTemplateTests { sampleEntity.setMessage((String) searchHit.getSource().get("message")); values.add(sampleEntity); } - return new FacetedPageImpl((List) values); + return new PageImpl((List) values); } }); assertThat(page, is(notNullValue())); @@ -1445,7 +1442,7 @@ public class ElasticsearchTemplateTests { .withTypes(TYPE_NAME).withQuery(matchAllQuery()).build(); Page sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, Map.class, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List chunk = new ArrayList(); for (SearchHit searchHit : response.getHits()) { if (response.getHits().getHits().length <= 0) { @@ -1460,7 +1457,7 @@ public class ElasticsearchTemplateTests { chunk.add(person); } if (chunk.size() > 0) { - return new FacetedPageImpl((List) chunk); + return new PageImpl((List) chunk); } return null; } @@ -1959,7 +1956,7 @@ public class ElasticsearchTemplateTests { SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).withTypes("hetro").withIndices(INDEX_1_NAME, INDEX_2_NAME).build(); Page page = elasticsearchTemplate.queryForPage(searchQuery, ResultAggregator.class, new SearchResultMapper() { @Override - public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + public Page mapResults(SearchResponse response, Class clazz, Pageable pageable) { List values = new ArrayList(); for (SearchHit searchHit : response.getHits()) { String id = String.valueOf(searchHit.getSource().get("id")); @@ -1967,7 +1964,7 @@ public class ElasticsearchTemplateTests { String lastName = StringUtils.isNotEmpty((String) searchHit.getSource().get("lastName")) ? (String) searchHit.getSource().get("lastName") : ""; values.add(new ResultAggregator(id, firstName, lastName)); } - return new FacetedPageImpl((List) values); + return new PageImpl((List) values); } }); diff --git a/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryTests.java b/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryTests.java index 55ebbd11b..0c4e9d786 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryTests.java @@ -350,7 +350,6 @@ public class CriteriaQueryTests { @Test public void shouldExecuteExpression() { // given - // todo List indexQueries = new ArrayList(); // first document String documentId = randomNumeric(5); diff --git a/src/test/java/org/springframework/data/elasticsearch/entities/SampleEntity.java b/src/test/java/org/springframework/data/elasticsearch/entities/SampleEntity.java index d98a93996..dd50d401a 100644 --- a/src/test/java/org/springframework/data/elasticsearch/entities/SampleEntity.java +++ b/src/test/java/org/springframework/data/elasticsearch/entities/SampleEntity.java @@ -19,6 +19,8 @@ import lombok.*; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Version; import org.springframework.data.elasticsearch.annotations.Document; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.ScriptedField; import org.springframework.data.elasticsearch.core.geo.GeoPoint; @@ -38,6 +40,7 @@ public class SampleEntity { @Id private String id; private String type; + @Field(type = FieldType.String) private String message; private int rate; @ScriptedField diff --git a/src/test/resources/test-home-dir/modules/lang-groovy/plugin-security.policy b/src/test/resources/test-home-dir/modules/lang-groovy/plugin-security.policy index 48ed2c456..521c93bf6 100644 --- a/src/test/resources/test-home-dir/modules/lang-groovy/plugin-security.policy +++ b/src/test/resources/test-home-dir/modules/lang-groovy/plugin-security.policy @@ -32,7 +32,7 @@ grant { // Standard set of classes permission org.elasticsearch.script.ClassPermission "<>"; - // groovy runtime (TODO: clean these up if possible) + // groovy runtime permission org.elasticsearch.script.ClassPermission "groovy.grape.GrabAnnotationTransformation"; permission org.elasticsearch.script.ClassPermission "groovy.json.JsonOutput"; permission org.elasticsearch.script.ClassPermission "groovy.lang.Binding"; diff --git a/template.mf b/template.mf index 70dcc48b8..e0b2d5ae1 100644 --- a/template.mf +++ b/template.mf @@ -11,8 +11,8 @@ Import-Template: org.apache.commons.collections.*;version="${commonscollections:[=.=.=,+1.0.0)}";resolution:=optional, org.apache.commons.lang.*;version="${commonslang:[=.=.=,+1.0.0)}", com.fasterxml.jackson.*;version="${jackson:[=.=.=,+1.0.0)}";resolution:=optional, - org.elasticsearch.*;version="${elasticsearch:[=.=.=,+1.4.4)}", - org.apache.lucene.*;version="4.10.4", + org.elasticsearch.*;version="${elasticsearch:[=.=.=,2.2.0)}", + org.apache.lucene.*;version="5.4.1", org.joda.time.*;version="${jodatime:[=.=.=,+1.0.0)}", org.slf4j.*;version="${slf4j:[=.=.=,+1.0.0)}", org.springframework.*;version="${spring:[=.=.=.=,+1.0.0)}",