Skip to content

Commit 5a9be86

Browse files
committed
HSEARCH-5300 Mention search DSL changes in the migration guide
1 parent 85a855d commit 5a9be86

File tree

1 file changed

+31
-0
lines changed
  • documentation/src/main/asciidoc/migration

1 file changed

+31
-0
lines changed

documentation/src/main/asciidoc/migration/index.adoc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,37 @@ to be in a more consistent format compared with other logging categories.
119119
- Hibernate Search now uses logging categories instead of class names to log messages.
120120
See link:https://docs.jboss.org/hibernate/search/{hibernateSearchVersionShort}/reference/en-US/html_single/#logging-categories-aggregated[Appendix B: List of all available logging categories]
121121
to find out what categories are available.
122+
- With introduction of the field references (`org.hibernate.search.engine.search.reference.pass:[*]`) most of the Search DSL
123+
interfaces (`org.hibernate.search.engine.search.pass:[*].dsl.pass:[*]`) got an extra type argument `SR` (scope root type).
124+
In simple scenarios where the query is created in one go there will be no code changes required:
125+
+
126+
[source,java,subs="+attributes"]
127+
----
128+
List<Book> result = searchSession.search( Book.class )
129+
.where( f -> f.match().field( "title" ).matching( "robot" ) )
130+
.fetchHits( 20 );
131+
----
132+
+
133+
In scenarios where there's work with the affected Search DSL interfaces is required user can choose between one of the following options:
134+
+
135+
====
136+
[source,java,subs="+attributes"]
137+
----
138+
var scope = searchSession.scope( Book.class ); // <1>
139+
SearchScope<?, Book> scope = searchSession.scope( Book.class ); // <2>
140+
SearchScope<Book, Book> scope = searchSession.scope( Book.class ); // <3>
141+
SearchScope<ReadingMaterial, ReadingMaterial> scope = searchSession.scope( List.of( Book.class, Magazine.class ) ); // <4>
142+
SearchScope<Book__, Book> scope = searchSession.scope( Book.class ); // <5>
143+
SearchScope<SomeRandomClass, Book> scope = searchSession.scope( Book.class ); // <6>
144+
----
145+
<1> Use `var` if possible. Otherwise, if you need to pass the DSL interfaces to some other methods as parameters,
146+
consider one of the following options:
147+
<2> Use the `?` wildcard.
148+
<3> Use the same type as your search entity.
149+
<4> Use the common supertype for a scope of multiple search entities.
150+
<5> Use the class generated for the static metamodel of this search entity.
151+
<6> Use any class.
152+
====
122153

123154
[[spi]]
124155
== SPI

0 commit comments

Comments
 (0)