3131
3232import com .google .cloud .firestore .CollectionReference ;
3333import com .google .cloud .firestore .GeoPoint ;
34- import com .google .cloud .firestore .LocalFirestoreHelper ;
3534import com .google .cloud .firestore .Pipeline ;
3635import com .google .cloud .firestore .PipelineResult ;
3736import com .google .cloud .firestore .WriteBatch ;
@@ -145,8 +144,8 @@ public void primeBackend() throws Exception {
145144 @ Before
146145 public void setupRestaurantDocs () throws Exception {
147146 assumeFalse (
148- "This test suite only runs against the Enterprise edition." ,
149- !getFirestoreEdition ().equals (FirestoreEdition .ENTERPRISE ));
147+ "This test suite only runs against the Enterprise edition." ,
148+ !getFirestoreEdition ().equals (FirestoreEdition .ENTERPRISE ));
150149
151150 restaurantsCollection = firestore .collection ("SearchIntegrationTests" );
152151
@@ -232,18 +231,17 @@ public void geoNearQuery() throws Exception {
232231 assertResultIds (snapshot , "solTacos" );
233232 }
234233
235-
236234 @ Test
237235 public void conjunctionOfTextSearchPredicates () throws Exception {
238236 Pipeline pipeline =
239237 firestore
240238 .pipeline ()
241239 .collection (restaurantsCollection .getId ())
242240 .search (
243- Search .withQuery (
244- and ( documentMatches ( "waffles" ), documentMatches ( "diner" )))
245- // TODO(search) switch back to field matches when supported by the backend
246- // and(field("menu").matches("waffles"), field("description").matches("diner")))
241+ Search .withQuery (and ( documentMatches ( "waffles" ), documentMatches ( "diner" )))
242+ // TODO(search) switch back to field matches when supported by the backend
243+ // and(field("menu").matches("waffles"),
244+ // field("description").matches("diner")))
247245 .withQueryEnhancement (Search .QueryEnhancement .DISABLED ));
248246
249247 Pipeline .Snapshot snapshot = pipeline .execute ().get ();
@@ -273,22 +271,22 @@ public void conjunctionOfTextSearchPredicates() throws Exception {
273271 @ Test
274272 public void negateMatch () throws Exception {
275273 Pipeline pipeline =
276- firestore
277- .pipeline ()
278- .collection (restaurantsCollection .getId ())
279- .search (
280- Search .withQuery (documentMatches ("-waffles" ))
281- .withQueryEnhancement (Search .QueryEnhancement .DISABLED ));
274+ firestore
275+ .pipeline ()
276+ .collection (restaurantsCollection .getId ())
277+ .search (
278+ Search .withQuery (documentMatches ("-waffles" ))
279+ .withQueryEnhancement (Search .QueryEnhancement .DISABLED ));
282280
283281 Pipeline .Snapshot snapshot = pipeline .execute ().get ();
284282 assertResultIds (
285- snapshot ,
286- "eastsideTacos" ,
287- "solTacos" ,
288- "peakBurgers" ,
289- "mileHighCatch" ,
290- "lotusBlossomThai" ,
291- "sunnySideUp" );
283+ snapshot ,
284+ "eastsideTacos" ,
285+ "solTacos" ,
286+ "peakBurgers" ,
287+ "mileHighCatch" ,
288+ "lotusBlossomThai" ,
289+ "sunnySideUp" );
292290 }
293291
294292 @ Test
@@ -320,19 +318,20 @@ public void rqueryAsQueryParam() throws Exception {
320318 }
321319
322320 // TODO(search) enable when rquery supports field paths
323- //@Test
324- //public void rquerySupportsFieldPaths() throws Exception {
321+ // @Test
322+ // public void rquerySupportsFieldPaths() throws Exception {
325323 // Pipeline pipeline =
326324 // firestore
327325 // .pipeline()
328326 // .collection(restaurantsCollection.getId())
329327 // .search(
330- // Search.withQuery("menu:(waffles OR pancakes) AND description:\"breakfast all day\"")
328+ // Search.withQuery("menu:(waffles OR pancakes) AND description:\"breakfast all
329+ // day\"")
331330 // .withQueryEnhancement(Search.QueryEnhancement.DISABLED));
332331 //
333332 // Pipeline.Snapshot snapshot = pipeline.execute().get();
334333 // assertResultIds(snapshot, "sunnySideUp");
335- //}
334+ // }
336335
337336 @ Test
338337 public void conjunctionOfRqueryAndExpression () throws Exception {
@@ -384,26 +383,26 @@ public void requireQueryExpansion_searchFullDocument() throws Exception {
384383 // }
385384
386385 // add fields
387- @ Test
388- public void addFields_topicalityScoreAndSnippet () throws Exception {
389- Pipeline pipeline =
390- firestore
391- .pipeline ()
392- .collection (restaurantsCollection .getId ())
393- .search (
394- Search .withQuery (documentMatches ("waffles" ))
395- .withAddFields (
396- score ().as ("searchScore" ), snippet ("menu" , "waffles" ).as ("snippet" ))
397- .withQueryEnhancement (Search .QueryEnhancement .DISABLED ))
398- .select ("name" , "searchScore" , "snippet" );
399-
400- Pipeline .Snapshot snapshot = pipeline .execute ().get ();
401- assertThat (snapshot .getResults ()).hasSize (1 );
402- PipelineResult result = snapshot .getResults ().get (0 );
403- assertThat (result .getData ().get ("name" )).isEqualTo ("The Golden Waffle" );
404- assertThat ((Double ) result .getData ().get ("searchScore" )).isGreaterThan (0.0 );
405- assertThat (((String ) result .getData ().get ("snippet" )).length ()).isGreaterThan (0 );
406- }
386+ @ Test
387+ public void addFields_topicalityScoreAndSnippet () throws Exception {
388+ Pipeline pipeline =
389+ firestore
390+ .pipeline ()
391+ .collection (restaurantsCollection .getId ())
392+ .search (
393+ Search .withQuery (documentMatches ("waffles" ))
394+ .withAddFields (
395+ score ().as ("searchScore" ), snippet ("menu" , "waffles" ).as ("snippet" ))
396+ .withQueryEnhancement (Search .QueryEnhancement .DISABLED ))
397+ .select ("name" , "searchScore" , "snippet" );
398+
399+ Pipeline .Snapshot snapshot = pipeline .execute ().get ();
400+ assertThat (snapshot .getResults ()).hasSize (1 );
401+ PipelineResult result = snapshot .getResults ().get (0 );
402+ assertThat (result .getData ().get ("name" )).isEqualTo ("The Golden Waffle" );
403+ assertThat ((Double ) result .getData ().get ("searchScore" )).isGreaterThan (0.0 );
404+ assertThat (((String ) result .getData ().get ("snippet" )).length ()).isGreaterThan (0 );
405+ }
407406
408407 // select
409408 @ Test
@@ -457,7 +456,7 @@ public void sort_byDistance() throws Exception {
457456 .pipeline ()
458457 .collection (restaurantsCollection .getId ())
459458 .search (
460- Search .withQuery (constant (true ))
459+ Search .withQuery (constant (true ))
461460 .withSort (
462461 field ("location" ).geoDistance (new GeoPoint (39.6985 , -105.024 )).ascending ())
463462 .withQueryEnhancement (Search .QueryEnhancement .DISABLED ));
@@ -476,7 +475,8 @@ public void sort_byDistance() throws Exception {
476475 // .search(
477476 // Search.withQuery(field("menu").matches("tacos OR chicken"))
478477 // .withSort(
479- // field("location").geoDistance(new GeoPoint(39.6985, -105.024)).ascending(),
478+ // field("location").geoDistance(new GeoPoint(39.6985,
479+ // -105.024)).ascending(),
480480 // score().descending())
481481 // .withQueryEnhancement(Search.QueryEnhancement.DISABLED));
482482 //
0 commit comments