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 21070a3 commit 6666087
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Expand Up @@ -90,9 +90,6 @@ If you want the actual entity instance, use the <<search-dsl-projection-entity,`
== `id`: return identifiers of matched entities

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 @@ -101,6 +98,9 @@ See also <<search-dsl-projected-value-type>>.
include::{sourcedir}/org/hibernate/search/documentation/search/projection/ProjectionDslIT.java[tags=id-int]
----
====
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>>.

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 Down
Expand Up @@ -8,6 +8,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -20,7 +21,6 @@
import org.hibernate.search.engine.search.query.SearchQuery;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper;
import org.hibernate.search.util.common.SearchException;
import org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer;
import org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex;
import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappedIndex;
import org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope;
Expand Down Expand Up @@ -167,13 +167,12 @@ private void initValues() {
}

private void initData() {
BulkIndexer indexer = index.bulkIndexer();
for ( int i = 0; i < 7; i++ ) {
int finalI = i;
indexer.add( ids[i], f -> f.addValue( index.binding().name, names[finalI] ) );
}

indexer.join();
index.bulkIndexer()
.add( 7, i -> documentProvider(
ids[i],
document -> document.addValue( index.binding().name, names[i] )
) )
.join();
}

private static class IndexBinding {
Expand Down

0 comments on commit 6666087

Please sign in to comment.