You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-6Lines changed: 42 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -314,8 +314,8 @@ The `EntityStream` is injected into the `PeopleService` using `@Autowired`. We c
314
314
#### 👭 Entity Meta-model
315
315
316
316
To produce more elaborate queries, you're provided with a generated metamodel, which is a class with the same name as your model but ending with a dollar sign. In the
317
-
example below, our entity model is `Person` therefore we get a metamodel named `Person$`. With the meta-model you have access to the operations related to the
318
-
underlying search engine field. For example, in the example we have an `age` property which is an integer. Therefore our metamodel has an `AGE` property which has
317
+
example below, our entity model is `Person` therefore we get a metamodel named `Person$`. With the metamodel you have access to the operations related to the
318
+
underlying search engine field. For example, in the example we have an `age` property which is an integer. Therefore, our metamodel has an `AGE` property which has
319
319
numeric operations we can use with the stream's `filter` method such as `between`.
320
320
321
321
```java
@@ -331,6 +331,42 @@ public Iterable<Person> findByAgeBetween(int minAge, int maxAge) {
331
331
332
332
In this example we also make use of the Streams `sorted` method to declare that our stream will be sorted by the `Person$.AGE` in `ASC`ending order.
333
333
334
+
Check out the full set of tests for [EntityStreams](https://github.com/redis/redis-om-spring/tree/main/redis-om-spring/src/test/java/com/redis/om/spring/search/stream)
335
+
336
+
### 👯️ Querying by Example (QBE)
337
+
338
+
Query by Example (QBE) is a user-friendly querying technique with a simple interface. It allows dynamic query creation
339
+
and does not require you to write queries that contain field names. In fact, Query by Example does not require you to
340
+
write queries by using store-specific query languages at all.
341
+
342
+
#### QBE Usage
343
+
344
+
The Query by Example API consists of four parts:
345
+
***Probe**: The actual example of a domain object with populated fields.
346
+
***ExampleMatcher**: The `ExampleMatcher` carries details on how to match particular fields. It can be reused across multiple `Examples`.
347
+
***Example**: An Example consists of the probe and the ExampleMatcher. It is used to create the query.
348
+
***FetchableFluentQuery**: A `FetchableFluentQuery` offers a fluent API, that allows further customization of a query derived from an `Example`.
349
+
Using the fluent API lets you specify ordering projection and result processing for your query.
350
+
351
+
Query by Example is well suited for several use cases:
352
+
353
+
* Querying your data store with a set of static or dynamic constraints.
354
+
* Frequent refactoring of the domain objects without worrying about breaking existing queries.
355
+
* Working independently of the underlying data store API.
356
+
357
+
For example, if you have an `@Document` or `@RedisHash` annotated entity you can create an instance, partially populate its
358
+
properties, create an `Example` from it, and used the `findAll` method to query for similar entities:
359
+
360
+
```java
361
+
MyDoc template =newMyDoc();
362
+
template.setTitle("hello world");
363
+
template.setTag(Set.of("artigo"));
364
+
365
+
Example<MyDoc> example =Example.of(template, ExampleMatcher.matchingAny());
0 commit comments