Skip to content

Commit aa1ff7c

Browse files
committed
docs: add documentation for numeric array containment search methods
Added comprehensive documentation for the new NumericField array search capabilities: 1. **entity-streams.adoc**: Added "Numeric Array Queries" section with examples of containsDouble(), containsLong(), and containsInt() methods for EntityStream filtering 2. **metamodel.adoc**: Added "Numeric Array Field Methods" section explaining the generated metamodel methods for type-safe numeric array containment searches 3. **index-annotations.adoc**: Added examples of indexing numeric arrays/collections and cross-referenced to the numeric array query documentation These methods provide functionality similar to TagField.in() but specifically designed for numeric arrays, addressing GitHub issue #400.
1 parent 727c3f9 commit aa1ff7c

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

docs/content/modules/ROOT/pages/entity-streams.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ List<Company> specificYears = entityStream.of(Company.class)
9191
.collect(Collectors.toList());
9292
----
9393

94+
=== Numeric Array Queries
95+
96+
For numeric array fields (indexed with `@Indexed` or `@NumericIndexed`), you can search for entities where the array contains any of the specified values:
97+
98+
[source,java]
99+
----
100+
// Find entities where double array contains any of the specified values
101+
List<DataAnalysis> highScores = entityStream.of(DataAnalysis.class)
102+
.filter(DataAnalysis$.SCORES.containsDouble(85.5, 92.3, 95.0))
103+
.collect(Collectors.toList());
104+
105+
// Find entities where long array contains any of the specified values
106+
List<Statistics> largeCounts = entityStream.of(Statistics.class)
107+
.filter(Statistics$.COUNTS.containsLong(1000L, 5000L, 10000L))
108+
.collect(Collectors.toList());
109+
110+
// Find entities where integer array contains any of the specified values
111+
List<Survey> topRated = entityStream.of(Survey.class)
112+
.filter(Survey$.RATINGS.containsInt(4, 5))
113+
.collect(Collectors.toList());
114+
----
115+
116+
NOTE: These methods work similarly to `TagField.in()` but are specifically designed for numeric arrays, providing type-safe array containment searches.
117+
94118
=== String Operations
95119

96120
[source,java]

docs/content/modules/ROOT/pages/index-annotations.adoc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,16 @@ public class Company {
221221
222222
@Indexed // Complex objects in collections
223223
private Set<Employee> employees;
224-
}
224+
225+
@Indexed // Numeric arrays support containment searches
226+
private List<Double> scores;
227+
228+
@Indexed // Works with primitive arrays too
229+
private int[] ratings;
225230
----
226231

232+
NOTE: Numeric arrays and collections indexed with `@Indexed` support containment searches using `containsDouble()`, `containsLong()`, and `containsInt()` methods on the generated metamodel fields. See xref:entity-streams.adoc#_numeric_array_queries[Numeric Array Queries] for examples.
233+
227234
== Index Configuration
228235

229236
=== @IndexingOptions

docs/content/modules/ROOT/pages/metamodel.adoc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,39 @@ public List<Product> findGamingLaptops() {
137137
}
138138
----
139139

140+
=== Numeric Array Field Methods
141+
142+
For `NumericField` instances that represent arrays or collections, additional methods are available for array containment queries:
143+
144+
[source,java]
145+
----
146+
@Document
147+
public class DataAnalysis {
148+
@Id
149+
private String id;
150+
151+
@Indexed
152+
private List<Double> measurements;
153+
154+
@Indexed
155+
private List<Long> counts;
156+
157+
@Indexed
158+
private List<Integer> ratings;
159+
}
160+
161+
// Generated metamodel provides specialized methods for numeric arrays
162+
public List<DataAnalysis> findByArrayContents() {
163+
return entityStream.of(DataAnalysis.class)
164+
.filter(DataAnalysis$.MEASUREMENTS.containsDouble(1.5, 2.5, 3.5)) // For double arrays
165+
.filter(DataAnalysis$.COUNTS.containsLong(100L, 200L, 300L)) // For long arrays
166+
.filter(DataAnalysis$.RATINGS.containsInt(4, 5)) // For int arrays
167+
.collect(Collectors.toList());
168+
}
169+
----
170+
171+
These methods work similarly to `TagField.in()` but provide type-safe containment searches specifically for numeric arrays.
172+
140173

141174
== Metamodel with Entity Streams
142175

0 commit comments

Comments
 (0)