This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DATASOLR-244 - Added Support for Combined Facet and Highlight Query.
Original Pull Request: #65 (David Webb)
- Loading branch information
1 parent
955f7c9
commit fe12122
Showing
17 changed files
with
714 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ava/org/springframework/data/solr/core/query/AbstractFacetAndHighlightQueryDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2012 - 2016 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.solr.core.query; | ||
|
||
/** | ||
* General purpose {@link FacetAndHighlightQuery} decorator. | ||
* | ||
* @author David Webb | ||
* @since 2.1.0 | ||
*/ | ||
public class AbstractFacetAndHighlightQueryDecorator extends AbstractQueryDecorator | ||
implements FacetQuery, HighlightQuery { | ||
|
||
private FacetAndHighlightQuery query; | ||
|
||
public AbstractFacetAndHighlightQueryDecorator(FacetAndHighlightQuery query) { | ||
|
||
super(query); | ||
this.query = query; | ||
} | ||
|
||
@Override | ||
public <T extends SolrDataQuery> T setHighlightOptions(HighlightOptions highlightOptions) { | ||
return query.setHighlightOptions(highlightOptions); | ||
} | ||
|
||
@Override | ||
public HighlightOptions getHighlightOptions() { | ||
return query.getHighlightOptions(); | ||
} | ||
|
||
@Override | ||
public boolean hasHighlightOptions() { | ||
return query.hasHighlightOptions(); | ||
} | ||
|
||
@Override | ||
public <T extends SolrDataQuery> T setFacetOptions(FacetOptions facetOptions) { | ||
return query.setFacetOptions(facetOptions); | ||
} | ||
|
||
@Override | ||
public FacetOptions getFacetOptions() { | ||
return query.getFacetOptions(); | ||
} | ||
|
||
@Override | ||
public boolean hasFacetOptions() { | ||
return query.hasFacetOptions(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/springframework/data/solr/core/query/FacetAndHighlightQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2012 - 2016 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.solr.core.query; | ||
|
||
/** | ||
* A Query that combines a {@link FacetQuery} and a {@link HighlightQuery} | ||
* | ||
* @author David Webb | ||
* @since 2.1.0 | ||
*/ | ||
public interface FacetAndHighlightQuery extends FacetQuery, HighlightQuery { | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/org/springframework/data/solr/core/query/SimpleFacetAndHighlightQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2012 - 2016 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.solr.core.query; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.util.Assert; | ||
|
||
/** | ||
* Trivial implementation of {@link FacetAndHighlightQuery} | ||
* | ||
* @author David Webb | ||
* @since 2.1.0 | ||
*/ | ||
public class SimpleFacetAndHighlightQuery extends SimpleQuery implements FacetAndHighlightQuery { | ||
|
||
private FacetOptions facetOptions; | ||
private HighlightOptions highlightOptions; | ||
|
||
public SimpleFacetAndHighlightQuery() { | ||
super(); | ||
} | ||
|
||
public SimpleFacetAndHighlightQuery(Criteria criteria) { | ||
this(criteria, null); | ||
} | ||
|
||
public SimpleFacetAndHighlightQuery(Criteria criteria, Pageable pageable) { | ||
super(criteria, pageable); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public final <T extends SolrDataQuery> T setFacetOptions(FacetOptions facetOptions) { | ||
if (facetOptions != null) { | ||
Assert.isTrue(facetOptions.hasFacets(), "Cannot set facet options having neither fields nor queries."); | ||
} | ||
this.facetOptions = facetOptions; | ||
return (T) this; | ||
} | ||
|
||
@Override | ||
public FacetOptions getFacetOptions() { | ||
return this.facetOptions; | ||
} | ||
|
||
@Override | ||
public boolean hasFacetOptions() { | ||
return this.getFacetOptions() != null; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T extends SolrDataQuery> T setHighlightOptions(HighlightOptions highlightOptions) { | ||
this.highlightOptions = highlightOptions; | ||
return (T) this; | ||
} | ||
|
||
@Override | ||
public HighlightOptions getHighlightOptions() { | ||
return this.highlightOptions; | ||
} | ||
|
||
@Override | ||
public boolean hasHighlightOptions() { | ||
return this.highlightOptions != null; | ||
} | ||
|
||
} |
Oops, something went wrong.