-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-4827 Don't allow some projections within a nested context
- Loading branch information
1 parent
f646ae1
commit fb76c0a
Showing
39 changed files
with
630 additions
and
14 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
26 changes: 26 additions & 0 deletions
26
...a/org/hibernate/search/backend/elasticsearch/reporting/impl/ElasticsearchSearchHints.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 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.elasticsearch.reporting.impl; | ||
|
||
import org.hibernate.search.engine.backend.reporting.spi.BackendSearchHints; | ||
import org.hibernate.search.util.common.logging.impl.MessageConstants; | ||
|
||
import org.jboss.logging.Messages; | ||
import org.jboss.logging.annotations.Message; | ||
import org.jboss.logging.annotations.MessageBundle; | ||
|
||
@MessageBundle(projectCode = MessageConstants.PROJECT_CODE) | ||
public interface ElasticsearchSearchHints extends BackendSearchHints { | ||
|
||
ElasticsearchSearchHints INSTANCE = Messages.getBundle( ElasticsearchSearchHints.class ); | ||
|
||
@Message(value = "A JSON hit projection represents a root hit object and adding it as a part of the nested object projection might produce misleading results.") | ||
String jsonHitProjectionNestingNotSupportedHint(); | ||
|
||
@Message(value = "A source projection represents a root source object and adding it as a part of the nested object projection might produce misleading results.") | ||
String sourceProjectionNestingNotSupportedHint(); | ||
} |
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
32 changes: 32 additions & 0 deletions
32
.../backend/elasticsearch/search/projection/impl/ElasticsearchEntityCompositeProjection.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,32 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.elasticsearch.search.projection.impl; | ||
|
||
import org.hibernate.search.backend.elasticsearch.reporting.impl.ElasticsearchSearchHints; | ||
import org.hibernate.search.backend.elasticsearch.search.common.impl.ElasticsearchSearchIndexScope; | ||
import org.hibernate.search.engine.search.projection.spi.ProjectionTypeKeys; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
public class ElasticsearchEntityCompositeProjection<E> extends AbstractElasticsearchProjection<E> { | ||
private final ElasticsearchSearchProjection<E> delegate; | ||
|
||
public ElasticsearchEntityCompositeProjection(ElasticsearchSearchIndexScope<?> scope, | ||
ElasticsearchSearchProjection<E> delegate) { | ||
super( scope ); | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public Extractor<?, E> request(JsonObject requestBody, ProjectionRequestContext context) { | ||
context.checkNotNested( | ||
ProjectionTypeKeys.ENTITY, | ||
ElasticsearchSearchHints.INSTANCE.entityProjectionNestingNotSupportedHint() | ||
); | ||
return delegate.request( requestBody, context ); | ||
} | ||
} |
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
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
22 changes: 22 additions & 0 deletions
22
.../search/backend/elasticsearch/search/projection/impl/ElasticsearchProjectionTypeKeys.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,22 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.elasticsearch.search.projection.impl; | ||
|
||
import static org.hibernate.search.engine.search.projection.spi.ProjectionTypeKeys.key; | ||
|
||
import org.hibernate.search.engine.search.common.spi.SearchQueryElementTypeKey; | ||
|
||
public final class ElasticsearchProjectionTypeKeys { | ||
|
||
private ElasticsearchProjectionTypeKeys() { | ||
} | ||
|
||
public static final SearchQueryElementTypeKey<?> JSON_HIT = key( "json-hit" ); | ||
public static final SearchQueryElementTypeKey<?> SOURCE = key( "source" ); | ||
public static final SearchQueryElementTypeKey<?> EXPLANATION = key( "explanation" ); | ||
|
||
} |
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
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
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
23 changes: 23 additions & 0 deletions
23
...e/src/main/java/org/hibernate/search/backend/lucene/reporting/impl/LuceneSearchHints.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,23 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.backend.lucene.reporting.impl; | ||
|
||
import org.hibernate.search.engine.backend.reporting.spi.BackendSearchHints; | ||
import org.hibernate.search.util.common.logging.impl.MessageConstants; | ||
|
||
import org.jboss.logging.Messages; | ||
import org.jboss.logging.annotations.Message; | ||
import org.jboss.logging.annotations.MessageBundle; | ||
|
||
@MessageBundle(projectCode = MessageConstants.PROJECT_CODE) | ||
public interface LuceneSearchHints extends BackendSearchHints { | ||
|
||
LuceneSearchHints INSTANCE = Messages.getBundle( LuceneSearchHints.class ); | ||
|
||
@Message("A document projection represents a root document and adding it as a part of the nested object projection might produce misleading results.") | ||
String documentProjectionNestingNotSupportedHint(); | ||
} |
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
Oops, something went wrong.