@@ -34,129 +34,166 @@ public void run()
34
34
// STEP_START data_sample
35
35
var bike1 = new
36
36
{
37
- Brand = "Diaz Ltd" ,
38
- Model = "Dealer Sl" ,
39
- Price = 7315.58M ,
40
- Description = "The Diaz Ltd Dealer Sl is a reliable choice" +
41
- " for urban cycling. The Diaz Ltd Dealer Sl " +
42
- "is a comfortable choice for urban cycling." ,
37
+ Brand = "Velorim" ,
38
+ Model = "Jigger" ,
39
+ Price = 270M ,
40
+ Description = "Small and powerful, the Jigger is the best ride " +
41
+ "for the smallest of tikes! This is the tiniest " +
42
+ "kids’ pedal bike on the market available without" +
43
+ " a coaster brake, the Jigger is the vehicle of " +
44
+ "choice for the rare tenacious little rider " +
45
+ "raring to go." ,
43
46
Condition = "used"
44
47
} ;
45
48
// STEP_END
46
49
47
- var bicycles = new [ ]
48
- {
49
- bike1 ,
50
- new
51
- {
52
- Brand = "Bridges Group" ,
53
- Model = "Project Pro" ,
54
- Price = 3610.82M ,
55
- Description =
56
- "This mountain bike is perfect for mountain biking. " +
57
- "The Bridges Group Project Pro is a responsive choice" +
58
- " for mountain biking." ,
59
- Condition = "used"
60
- } ,
61
- new
62
- {
63
- Brand = "Vega, Cole and Miller" ,
64
- Model = "Group Advanced" ,
65
- Price = 8961.42M ,
66
- Description =
67
- "The Vega, Cole and Miller Group Advanced provides an " +
68
- "excellent ride. With its fast carbon frame and 24 gears," +
69
- " this bicycle is perfect for any terrain." ,
70
- Condition = "used"
71
- } ,
72
- new
73
- {
74
- Brand = "Powell-Montgomery" ,
75
- Model = "Angle Race" ,
76
- Price = 4050.27M ,
77
- Description =
78
- "The Powell-Montgomery Angle Race is a smooth choice for" +
79
- " road cycling. The Powell-Montgomery Angle Race" +
80
- " provides a durable ride." ,
81
- Condition = "used"
82
- } ,
83
- new
84
- {
85
- Brand = "Gill-Lewis" ,
86
- Model = "Action Evo" ,
87
- Price = 283.68M ,
88
- Description =
89
- "The Gill-Lewis Action Evo provides a smooth ride. " +
90
- "The Gill-Lewis Action Evo provides an excellent ride." ,
91
- Condition = "used"
92
- } ,
93
- new
94
- {
95
- Brand = "Rodriguez-Guerrero" ,
96
- Model = "Drama Comp" ,
97
- Price = 4462.55M ,
98
- Description =
99
- "This kids bike is perfect for young riders. With its " +
100
- "excellent aluminum frame and 12 gears, this bicycle " +
101
- "is perfect for any terrain." ,
102
- Condition = "new"
103
- } ,
104
- new
105
- {
106
- Brand = "Moore PLC" ,
107
- Model = "Award Race" ,
108
- Price = 3790.76M ,
109
- Description =
110
- "This olive folding bike features a carbon frame and" +
111
- " 27.5 inch wheels. This folding bike is perfect for" +
112
- " compact storage and transportation." ,
113
- Condition = "new"
114
- } ,
115
- new
116
- {
117
- Brand = "Hall, Haley and Hayes" ,
118
- Model = "Weekend Plus" ,
119
- Price = 2008.4M ,
120
- Description =
121
- "The Hall, Haley and Hayes Weekend Plus provides a" +
122
- " comfortable ride. This blue kids bike features a" +
123
- " steel frame and 29.0 inch wheels." ,
124
- Condition = "new"
125
- } ,
126
- new
127
- {
128
- Brand = "Peck-Carson" ,
129
- Model = "Sun Hybrid" ,
130
- Price = 9874.95M ,
131
- Description =
132
- "With its comfortable aluminum frame and 25 gears," +
133
- " this bicycle is perfect for any terrain. The " +
134
- "Peck-Carson Sun Hybrid provides a comfortable ride." ,
135
- Condition = "new"
136
- } ,
137
- new
50
+ var bicycles = new object [ ]
138
51
{
139
- Brand = "Fowler Ltd" ,
140
- Model = "Weekend Trail" ,
141
- Price = 3833.71M ,
142
- Description =
143
- "The Fowler Ltd Letter Trail is a comfortable choice" +
144
- " for transporting cargo. This cargo bike is " +
145
- "perfect for transporting cargo." ,
146
- Condition = "refurbished"
147
- }
148
- } ;
52
+ bike1 ,
53
+ new
54
+ {
55
+ Brand = "Bicyk" ,
56
+ Model = "Hillcraft" ,
57
+ Price = 1200M ,
58
+ Description = "Kids want to ride with as little weight as possible." +
59
+ " Especially on an incline! They may be at the age " +
60
+ "when a 27.5 inch wheel bike is just too clumsy coming " +
61
+ "off a 24 inch bike. The Hillcraft 26 is just the solution" +
62
+ " they need!" ,
63
+ Condition = "used" ,
64
+ } ,
65
+ new
66
+ {
67
+ Brand = "Nord" ,
68
+ Model = "Chook air 5" ,
69
+ Price = 815M ,
70
+ Description = "The Chook Air 5 gives kids aged six years and older " +
71
+ "a durable and uberlight mountain bike for their first" +
72
+ " experience on tracks and easy cruising through forests" +
73
+ " and fields. The lower top tube makes it easy to mount" +
74
+ " and dismount in any situation, giving your kids greater" +
75
+ " safety on the trails." ,
76
+ Condition = "used" ,
77
+ } ,
78
+ new
79
+ {
80
+ Brand = "Eva" ,
81
+ Model = "Eva 291" ,
82
+ Price = 3400M ,
83
+ Description = "The sister company to Nord, Eva launched in 2005 as the" +
84
+ " first and only women-dedicated bicycle brand. Designed" +
85
+ " by women for women, allEva bikes are optimized for the" +
86
+ " feminine physique using analytics from a body metrics" +
87
+ " database. If you like 29ers, try the Eva 291. It’s a " +
88
+ "brand new bike for 2022.. This full-suspension, " +
89
+ "cross-country ride has been designed for velocity. The" +
90
+ " 291 has 100mm of front and rear travel, a superlight " +
91
+ "aluminum frame and fast-rolling 29-inch wheels. Yippee!" ,
92
+ Condition = "used" ,
93
+ } ,
94
+ new
95
+ {
96
+ Brand = "Noka Bikes" ,
97
+ Model = "Kahuna" ,
98
+ Price = 3200M ,
99
+ Description = "Whether you want to try your hand at XC racing or are " +
100
+ "looking for a lively trail bike that's just as inspiring" +
101
+ " on the climbs as it is over rougher ground, the Wilder" +
102
+ " is one heck of a bike built specifically for short women." +
103
+ " Both the frames and components have been tweaked to " +
104
+ "include a women’s saddle, different bars and unique " +
105
+ "colourway." ,
106
+ Condition = "used" ,
107
+ } ,
108
+ new
109
+ {
110
+ Brand = "Breakout" ,
111
+ Model = "XBN 2.1 Alloy" ,
112
+ Price = 810M ,
113
+ Description = "The XBN 2.1 Alloy is our entry-level road bike – but that’s" +
114
+ " not to say that it’s a basic machine. With an internal " +
115
+ "weld aluminium frame, a full carbon fork, and the slick-shifting" +
116
+ " Claris gears from Shimano’s, this is a bike which doesn’t" +
117
+ " break the bank and delivers craved performance." ,
118
+ Condition = "new" ,
119
+ } ,
120
+ new
121
+ {
122
+ Brand = "ScramBikes" ,
123
+ Model = "WattBike" ,
124
+ Price = 2300M ,
125
+ Description = "The WattBike is the best e-bike for people who still feel young" +
126
+ " at heart. It has a Bafang 1000W mid-drive system and a 48V" +
127
+ " 17.5AH Samsung Lithium-Ion battery, allowing you to ride for" +
128
+ " more than 60 miles on one charge. It’s great for tackling hilly" +
129
+ " terrain or if you just fancy a more leisurely ride. With three" +
130
+ " working modes, you can choose between E-bike, assisted bicycle," +
131
+ " and normal bike modes." ,
132
+ Condition = "new" ,
133
+ } ,
134
+ new
135
+ {
136
+ Brand = "Peaknetic" ,
137
+ Model = "Secto" ,
138
+ Price = 430M ,
139
+ Description = "If you struggle with stiff fingers or a kinked neck or back after" +
140
+ " a few minutes on the road, this lightweight, aluminum bike" +
141
+ " alleviates those issues and allows you to enjoy the ride. From" +
142
+ " the ergonomic grips to the lumbar-supporting seat position, the" +
143
+ " Roll Low-Entry offers incredible comfort. The rear-inclined seat" +
144
+ " tube facilitates stability by allowing you to put a foot on the" +
145
+ " ground to balance at a stop, and the low step-over frame makes it" +
146
+ " accessible for all ability and mobility levels. The saddle is" +
147
+ " very soft, with a wide back to support your hip joints and a" +
148
+ " cutout in the center to redistribute that pressure. Rim brakes" +
149
+ " deliver satisfactory braking control, and the wide tires provide" +
150
+ " a smooth, stable ride on paved roads and gravel. Rack and fender" +
151
+ " mounts facilitate setting up the Roll Low-Entry as your preferred" +
152
+ " commuter, and the BMX-like handlebar offers space for mounting a" +
153
+ " flashlight, bell, or phone holder." ,
154
+ Condition = "new" ,
155
+ } ,
156
+ new
157
+ {
158
+ Brand = "nHill" ,
159
+ Model = "Summit" ,
160
+ Price = 1200M ,
161
+ Description = "This budget mountain bike from nHill performs well both on bike" +
162
+ " paths and on the trail. The fork with 100mm of travel absorbs" +
163
+ " rough terrain. Fat Kenda Booster tires give you grip in corners" +
164
+ " and on wet trails. The Shimano Tourney drivetrain offered enough" +
165
+ " gears for finding a comfortable pace to ride uphill, and the" +
166
+ " Tektro hydraulic disc brakes break smoothly. Whether you want an" +
167
+ " affordable bike that you can take to work, but also take trail in" +
168
+ " mountains on the weekends or you’re just after a stable," +
169
+ " comfortable ride for the bike path, the Summit gives a good value" +
170
+ " for money." ,
171
+ Condition = "new" ,
172
+ } ,
173
+ new
174
+ {
175
+ Model = "ThrillCycle" ,
176
+ Brand = "BikeShind" ,
177
+ Price = 815M ,
178
+ Description = "An artsy, retro-inspired bicycle that’s as functional as it is" +
179
+ " pretty: The ThrillCycle steel frame offers a smooth ride. A" +
180
+ " 9-speed drivetrain has enough gears for coasting in the city, but" +
181
+ " we wouldn’t suggest taking it to the mountains. Fenders protect" +
182
+ " you from mud, and a rear basket lets you transport groceries," +
183
+ " flowers and books. The ThrillCycle comes with a limited lifetime" +
184
+ " warranty, so this little guy will last you long past graduation." ,
185
+ Condition = "refurbished" ,
186
+ } ,
187
+ } ;
149
188
150
- // STEP_START define_index
189
+ // STEP_START create_index
151
190
var schema = new Schema ( )
152
191
. AddTextField ( new FieldName ( "$.Brand" , "Brand" ) )
153
192
. AddTextField ( new FieldName ( "$.Model" , "Model" ) )
154
193
. AddTextField ( new FieldName ( "$.Description" , "Description" ) )
155
194
. AddNumericField ( new FieldName ( "$.Price" , "Price" ) )
156
195
. AddTagField ( new FieldName ( "$.Condition" , "Condition" ) ) ;
157
- // STEP_END
158
196
159
- // STEP_START create_index
160
197
ft . Create (
161
198
"idx:bicycle" ,
162
199
new FTCreateParams ( ) . On ( IndexDataType . JSON ) . Prefix ( "bicycle:" ) ,
@@ -170,29 +207,67 @@ public void run()
170
207
}
171
208
// STEP_END
172
209
210
+ // STEP_START wildcard_query
211
+ var query1 = new Query ( "*" ) ;
212
+ var res1 = ft . Search ( "idx:bicycle" , query1 ) . Documents ;
213
+ Console . WriteLine ( string . Join ( "\n " , res1 . Count ( ) ) ) ;
214
+ // Prints: Documents found: 10
215
+ // STEP_END
216
+ // REMOVE_START
217
+ Assert . Equal ( 10 , res1 . Count ( ) ) ;
218
+ // REMOVE_END
219
+
220
+ // STEP_START query_single_term
221
+ var query2 = new Query ( "@Model:Jigger" ) ;
222
+ var res2 = ft . Search ( "idx:bicycle" , query2 ) . Documents ;
223
+ Console . WriteLine ( string . Join ( "\n " , res2 . Select ( x => x [ "json" ] ) ) ) ;
224
+ // Prints: {"Brand":"Moore PLC","Model":"Award Race","Price":3790.76,
225
+ // "Description":"This olive folding bike features a carbon frame
226
+ // and 27.5 inch wheels. This folding bike is perfect for compact
227
+ // storage and transportation.","Condition":"new"}
228
+ // STEP_END
229
+ // REMOVE_START
230
+ Assert . Single ( res2 ) ;
231
+ Assert . Equal ( "bicycle:0" , res2 [ 0 ] . Id ) ;
232
+ // REMOVE_END
233
+
173
234
// STEP_START query_single_term_and_num_range
174
- var query = new Query ( "folding @Price:[1000 4000]" ) ;
175
- var res = ft . Search ( "idx:bicycle" , query ) . Documents ;
176
- Console . WriteLine ( string . Join ( "\n " , res . Select ( x => x [ "json" ] ) ) ) ;
235
+ var query3 = new Query ( "basic @Price:[500 1000]" ) ;
236
+ var res3 = ft . Search ( "idx:bicycle" , query3 ) . Documents ;
237
+ Console . WriteLine ( string . Join ( "\n " , res3 . Select ( x => x [ "json" ] ) ) ) ;
238
+ // Prints: {"Brand":"Moore PLC","Model":"Award Race","Price":3790.76,
239
+ // "Description":"This olive folding bike features a carbon frame
240
+ // and 27.5 inch wheels. This folding bike is perfect for compact
241
+ // storage and transportation.","Condition":"new"}
242
+ // STEP_END
243
+ // REMOVE_START
244
+ Assert . Single ( res3 ) ;
245
+ Assert . Equal ( "bicycle:5" , res3 [ 0 ] . Id ) ;
246
+ // REMOVE_END
247
+
248
+ // STEP_START query_exact_matching
249
+ var query4 = new Query ( "@Brand:\" Noka Bikes\" " ) ;
250
+ var res4 = ft . Search ( "idx:bicycle" , query4 ) . Documents ;
251
+ Console . WriteLine ( string . Join ( "\n " , res4 . Select ( x => x [ "json" ] ) ) ) ;
177
252
// Prints: {"Brand":"Moore PLC","Model":"Award Race","Price":3790.76,
178
253
// "Description":"This olive folding bike features a carbon frame
179
254
// and 27.5 inch wheels. This folding bike is perfect for compact
180
255
// storage and transportation.","Condition":"new"}
181
256
// STEP_END
182
257
// REMOVE_START
183
- Assert . Single ( res ) ;
184
- Assert . Equal ( "bicycle:6 " , res [ 0 ] . Id ) ;
258
+ Assert . Single ( res4 ) ;
259
+ Assert . Equal ( "bicycle:4 " , res4 [ 0 ] . Id ) ;
185
260
// REMOVE_END
186
261
187
262
// STEP_START query_single_term_limit_fields
188
- var cargoQuery = new Query ( "cargo " ) . ReturnFields ( "Price" ) ;
189
- var cargoRes = ft . Search ( "idx:bicycle" , cargoQuery ) . Documents ;
190
- Console . WriteLine ( cargoRes . First ( ) [ "Price" ] ) ;
191
- // Prints: 3833.71
263
+ var query5 = new Query ( "@Model:Jigger " ) . ReturnFields ( "Price" ) ;
264
+ var res5 = ft . Search ( "idx:bicycle" , query5 ) . Documents ;
265
+ Console . WriteLine ( res5 . First ( ) [ "Price" ] ) ;
266
+ // Prints: 270
192
267
// STEP_END
193
268
// REMOVE_START
194
- Assert . Single ( cargoRes ) ;
195
- Assert . Equal ( "bicycle:9 " , cargoRes [ 0 ] . Id ) ;
269
+ Assert . Single ( res5 ) ;
270
+ Assert . Equal ( "bicycle:0 " , res5 [ 0 ] . Id ) ;
196
271
// REMOVE_END
197
272
198
273
// STEP_START simple_aggregation
0 commit comments