Skip to content

Commit

Permalink
HSEARCH-4142 Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Yoann Rodière <yoann@hibernate.org>
  • Loading branch information
fax4ever and yrodiere committed Mar 1, 2021
1 parent 85566c0 commit debd054
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Expand Up @@ -87,10 +87,12 @@ include::{sourcedir}/org/hibernate/search/documentation/search/projection/Projec
NOTE: The entity does not get loaded as part of the projection.
If you want the actual entity instance, use the <<search-dsl-projection-entity,`entity` projection>>

== `id`: return ids to matched entities
== `id`: return identifiers of matched entities

The `id` projection returns the id to the matched entity.
The API allows to express the expected entity type of the returning ids.
The `identifier` projection returns the identifier of the matched entity.
NOTE: If the provided identifier type does not match the type of identifiers for targeted entity types,
an exception will be thrown.
See also <<search-dsl-projected-value-type>>.

.Returning ids to matched entities, providing the identity type.
====
Expand All @@ -99,6 +101,7 @@ The API allows to express the expected entity type of the returning ids.
include::{sourcedir}/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java[tags=id-int]
----
====
You can omit the "identifier type" argument, but then you will get projections of type `Object`:

.Returning ids to matched entities, without providing the identity type.
====
Expand All @@ -108,9 +111,6 @@ include::{sourcedir}/org/hibernate/search/documentation/search/projection/Projec
----
====

NOTE: If the provided identity type does not match the current returned ids,
an exception will be thrown.

[[search-dsl-projection-entity]]
== `entity`: return matched entities

Expand Down
Expand Up @@ -47,11 +47,6 @@ public interface SearchProjectionFactory<R, E> {
/**
* Project to the identifier of the referenced entity,
* i.e. the value of the property marked as {@code @DocumentId}.
* <p>
* The actual type of the reference depends on the mapper used to create the query:
* the ORM mapper will return a the identifier, for example.
* <p>
* Using this method we do not provide any assumption about the type of the identifier.
*
* @return A DSL step where the "id" projection can be defined in more details.
*/
Expand All @@ -62,13 +57,8 @@ default IdProjectionOptionsStep<?, Object> id() {
/**
* Project to the identifier of the referenced entity,
* i.e. the value of the property marked as {@code @DocumentId}.
* <p>
* The actual type of the reference depends on the mapper used to create the query:
* the ORM mapper will return a the identifier, for example.
* <p>
* Using this method we assume that the type of the identifier is a subtype of {@code identifierType}.
*
* @param <I> The resulting type of the identifier
* @param <I> The expected type of the identifier
* @param identifierType The expected type of the identifier
* @return A DSL step where the "id" projection can be defined in more details.
* @throws SearchException if the identifier type doesn't match
Expand Down

0 comments on commit debd054

Please sign in to comment.