Skip to content

Commit eae3837

Browse files
committed
update sample
1 parent f6c8288 commit eae3837

File tree

18 files changed

+554
-128
lines changed

18 files changed

+554
-128
lines changed

astra-db-java/src/main/java/com/datastax/astra/client/collections/commands/cursor/CollectionFindAndRerankCursor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ public class CollectionFindAndRerankCursor<T, R> extends AbstractCursor<T, Reran
6868
* Input Find options. Where will change the different options.
6969
* Immutable as not setter is provided.
7070
*/
71-
private CollectionFindAndRerankOptions options;
71+
private final CollectionFindAndRerankOptions options;
7272

73+
/**
74+
* Type of results (different from inputs when projection is used)
75+
*/
7376
private Class<R> newRowType;
7477

7578
/**
@@ -81,6 +84,8 @@ public class CollectionFindAndRerankCursor<T, R> extends AbstractCursor<T, Reran
8184
* current filter
8285
* @param options
8386
* options of the find operation
87+
* @param recordType
88+
* the type of the record
8489
*/
8590
@SuppressWarnings("unchecked")
8691
public CollectionFindAndRerankCursor(Collection<T> dataSource, Filter filter, CollectionFindAndRerankOptions options, Class<R> recordType) {
@@ -136,7 +141,8 @@ public CollectionFindAndRerankCursor<T, R> filter(Filter newFilter) {
136141
/**
137142
* Creates a new {@link CollectionFindAndRerankCursor} with an updated projection.
138143
*
139-
* @param newProjection the new projection to apply
144+
* @param newProjection
145+
* the new projection to apply
140146
* @return a new {@link CollectionFindAndRerankCursor} instance with the specified projection
141147
*/
142148
public CollectionFindAndRerankCursor<T, R> project(Projection... newProjection) {
@@ -149,7 +155,8 @@ public CollectionFindAndRerankCursor<T, R> project(Projection... newProjection)
149155
/**
150156
* Creates a new {@link CollectionFindAndRerankCursor} with a specified sort order.
151157
*
152-
* @param sort the sort criteria to apply
158+
* @param sort
159+
* the sort criteria to apply
153160
* @return a new {@link CollectionFindAndRerankCursor} instance with the specified sort order
154161
*/
155162
public CollectionFindAndRerankCursor<T, R> sort(Sort... sort) {

astra-db-java/src/main/java/com/datastax/astra/client/collections/definition/CollectionDefinition.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,17 +427,19 @@ public CollectionDefinition rerank(CollectionRerankOptions collectionRerankOptio
427427
/**
428428
* Builder pattern.
429429
*
430-
* @param reranker
431-
* reranker
430+
* @param provider
431+
* reranker provider
432+
* @param model
433+
* model
432434
* @return self reference
433435
*/
434-
public CollectionDefinition rerank(String reranker) {
436+
public CollectionDefinition rerank(String provider, String model) {
435437
if (getRerank() == null) {
436438
rerank = new CollectionRerankOptions().enabled(true);
437439
}
438440
getRerank()
439441
.enabled(true)
440-
.service(new RerankServiceOptions().provider(reranker));
442+
.service(new RerankServiceOptions().provider(provider).modelName(model));
441443
return this;
442444
}
443445

astra-db-java/src/main/java/com/datastax/astra/client/collections/definition/documents/Document.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public <T> Document id(T id) {
358358
* self reference
359359
*/
360360
public Document vectorize(String passage) {
361-
return appendIfNotNull(DataAPIKeywords.VECTORIZE.getKeyword(), Vectorize.of(passage));
361+
return appendIfNotNull(DataAPIKeywords.VECTORIZE.getKeyword(), new Vectorize(passage));
362362
}
363363

364364
/**
@@ -385,7 +385,7 @@ public Document vectorize(Vectorize vectorize) {
385385
*/
386386
@BetaPreview
387387
public Document vectorize(String passage, String setPassage) {
388-
return appendIfNotNull(DataAPIKeywords.VECTORIZE.getKeyword(), Vectorize.of(passage, setPassage));
388+
return appendIfNotNull(DataAPIKeywords.VECTORIZE.getKeyword(), new Vectorize(passage, setPassage));
389389
}
390390

391391
/**

astra-db-java/src/main/java/com/datastax/astra/client/core/hybrid/HybridLimits.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,48 @@
2626
import java.util.HashMap;
2727
import java.util.Map;
2828

29+
/**
30+
* Represents the limits for lexical and vector data.
31+
*/
2932
@Data
3033
public class HybridLimits {
3134

35+
/**
36+
* The limit for the hybrid data when vectorize and lexical are used.
37+
*/
3238
Integer limit;
3339

40+
/**
41+
* The limit for the lexical data.
42+
*/
3443
Map<String, Integer> mapOfLimits;
3544

45+
/**
46+
* Constructor.
47+
*
48+
* @param limit
49+
* the limit for the hybrid data.
50+
*/
3651
public HybridLimits(Integer limit) {
3752
this.limit = limit;
3853
}
3954

55+
/**
56+
* Constructor.
57+
*
58+
* @param mapOfLimits
59+
* the map of limits for the hybrid data.
60+
*/
4061
public HybridLimits(Map<String, Integer> mapOfLimits) {
4162
this.mapOfLimits = mapOfLimits;
4263
}
4364

65+
/**
66+
* Add a limit for the lexical data.
67+
*
68+
* @param limit
69+
* lexical limit.
70+
*/
4471
public HybridLimits lexical(Integer limit) {
4572
if (mapOfLimits == null) {
4673
mapOfLimits = new HashMap<>();
@@ -49,6 +76,12 @@ public HybridLimits lexical(Integer limit) {
4976
return this;
5077
}
5178

79+
/**
80+
* Add a limit for the vector data.
81+
*
82+
* @param limit
83+
* vector limit.
84+
*/
5285
public HybridLimits vector(Integer limit) {
5386
if (mapOfLimits == null) {
5487
mapOfLimits = new HashMap<>();

astra-db-java/src/main/java/com/datastax/astra/client/core/lexical/Analyzer.java

Lines changed: 101 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,100 @@
2323
import com.datastax.astra.internal.serdes.core.AnalyzerSerializer;
2424
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2525
import lombok.Data;
26+
import lombok.Getter;
2627
import lombok.NoArgsConstructor;
2728

2829
import java.util.List;
2930
import java.util.Map;
3031

32+
/**
33+
* Analyzer used for indexing and searching 'lexical' data.
34+
*/
3135
@Data
3236
@JsonSerialize(using = AnalyzerSerializer.class)
3337
public class Analyzer {
3438

35-
/** In the case of String analyzer */
39+
/** Analyzer definition as a string like 'standard' */
3640
String strAnalyzer;
3741

38-
/** In the case of Document analyzer, free structure */
42+
/**
43+
* Represents the tokenizer used by the analyzer.
44+
*/
3945
LexicalFilter tokenizer;
4046

47+
/** Represents the filters for a text analyzer */
4148
List<LexicalFilter> filters;
4249

50+
/** Represents the char filters for a text analyzer */
4351
List<LexicalFilter> charFilters;
4452

53+
/**
54+
* Default constructor.
55+
*/
4556
public Analyzer() {
4657
}
4758

59+
/**
60+
* Constructor with analyzer definition.
61+
*
62+
* @param strAnalyzer
63+
* the analyzer definition
64+
*/
4865
public Analyzer(String strAnalyzer) {
4966
this.strAnalyzer = strAnalyzer;
5067
}
5168

69+
/**
70+
* Constructor with analyzer type.
71+
*
72+
* @param strAnalyzer
73+
* the analyzer type
74+
*/
75+
public Analyzer(AnalyzerTypes strAnalyzer) {
76+
this(strAnalyzer.getValue());
77+
}
78+
79+
/**
80+
* Define a tokenizer by its name.
81+
*
82+
* @param name
83+
* the analyzer name
84+
*/
5285
public Analyzer tokenizer(String name) {
5386
return tokenizer(name, null);
5487
}
88+
89+
/**
90+
* Define a tokenizer by its name and arguments.
91+
*
92+
* @param name
93+
* the analyzer name
94+
* @param args
95+
* the arguments for the analyzer
96+
*/
5597
public Analyzer tokenizer(String name, Map<String, String> args) {
5698
this.tokenizer = new LexicalFilter().name(name).args(args);;
5799
return this;
58100
}
59101

102+
/**
103+
* Adds a filter to the analyzer.
104+
*
105+
* @param name
106+
* the name of the filter
107+
*/
60108
public Analyzer addFilter(String name) {
61109
return addFilter(name, null);
62110
}
111+
112+
/**
113+
* Adds a filter to the analyzer.
114+
*
115+
* @param name
116+
* the name of the filter
117+
* @param args
118+
* the arguments for the filter
119+
*/
63120
public Analyzer addFilter(String name, Map<String, String> args) {
64121
if (filters == null) {
65122
filters = new java.util.ArrayList<>();
@@ -68,9 +125,24 @@ public Analyzer addFilter(String name, Map<String, String> args) {
68125
return this;
69126
}
70127

128+
/**
129+
* Adds a char filter to the analyzer.
130+
*
131+
* @param name
132+
* the name of the filter
133+
*/
71134
public Analyzer addChartFilter(String name) {
72135
return addChartFilter(name, null);
73136
}
137+
138+
/**
139+
* Adds a char filter to the analyzer.
140+
*
141+
* @param name
142+
* the name of the filter
143+
* @param args
144+
* the arguments for the filter
145+
*/
74146
public Analyzer addChartFilter(String name, Map<String, String> args) {
75147
if (charFilters == null) {
76148
charFilters = new java.util.ArrayList<>();
@@ -79,44 +151,56 @@ public Analyzer addChartFilter(String name, Map<String, String> args) {
79151
return this;
80152
}
81153

82-
public Analyzer(AnalyzerTypes strAnalyzer) {
83-
this.strAnalyzer = strAnalyzer.getValue();
84-
}
85-
154+
/**
155+
* Definition of filters and tokenizers
156+
*/
157+
@Getter
86158
@NoArgsConstructor
87159
public static class LexicalFilter {
88160

161+
/** Name of the filter */
89162
String name;
90163

164+
/** Arguments for the filter */
91165
Map<String, String> args;
92166

167+
/**
168+
* Sets the name of the filter.
169+
*
170+
* @param name
171+
* the name of the filter
172+
*/
93173
public LexicalFilter name(String name) {
94174
this.name = name;
95175
return this;
96176
}
97177

178+
/**
179+
* Sets the arguments for the filter.
180+
*
181+
* @param args
182+
* the arguments for the filter
183+
*/
98184
public LexicalFilter args(Map<String, String> args) {
99185
this.args = args;
100186
return this;
101187
}
102188

103-
public LexicalFilter arg(String key, String value) {
189+
/**
190+
* Adds an argument to the filter.
191+
*
192+
* @param key
193+
* the key of the argument
194+
* @param value
195+
* the value of the argument
196+
*/
197+
public LexicalFilter addArg(String key, String value) {
104198
if (args == null) {
105199
args = new java.util.HashMap<>();
106200
}
107201
args.put(key, value);
108202
return this;
109203
}
110-
111-
public String getName() {
112-
return name;
113-
}
114-
115-
public Map<String, String> getArgs() {
116-
return args;
117-
}
118204
}
119205

120-
121-
122206
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy