diff --git a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymboardSearchApplication.java b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymboardSearchApplication.java index aba27e9..0e7f79d 100644 --- a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymboardSearchApplication.java +++ b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymboardSearchApplication.java @@ -1,5 +1,6 @@ package nl.andrewlalis.gymboardsearch; +import nl.andrewlalis.gymboardsearch.index.GymIndexGenerator; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/SearchController.java b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/SearchController.java index df324fc..ed90431 100644 --- a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/SearchController.java +++ b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/SearchController.java @@ -1,6 +1,7 @@ package nl.andrewlalis.gymboardsearch; import nl.andrewlalis.gymboardsearch.dto.GymResponse; +import nl.andrewlalis.gymboardsearch.index.GymIndexSearcher; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; diff --git a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymIndexGenerator.java b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/index/GymIndexGenerator.java similarity index 79% rename from gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymIndexGenerator.java rename to gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/index/GymIndexGenerator.java index 46305b9..3193c87 100644 --- a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymIndexGenerator.java +++ b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/index/GymIndexGenerator.java @@ -1,5 +1,6 @@ -package nl.andrewlalis.gymboardsearch; +package nl.andrewlalis.gymboardsearch.index; +import nl.andrewlalis.gymboardsearch.DbUtils; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.*; @@ -24,7 +25,7 @@ import java.sql.ResultSet; public class GymIndexGenerator { private static final Logger log = LoggerFactory.getLogger(GymIndexGenerator.class); - void generateIndex() throws Exception { + public void generateIndex() throws Exception { log.info("Starting Gym index generation."); Path gymIndexDir = Path.of("gym-index"); FileSystemUtils.deleteRecursively(gymIndexDir); @@ -51,13 +52,13 @@ public class GymIndexGenerator { BigDecimal longitude = resultSet.getBigDecimal("longitude"); Document doc = new Document(); - doc.add(new StringField("short_name", shortName, Field.Store.YES)); - doc.add(new StringField("display_name", displayName, Field.Store.YES)); - doc.add(new StringField("city_short_name", cityShortName, Field.Store.YES)); - doc.add(new StringField("city_name", cityName, Field.Store.YES)); - doc.add(new StringField("country_code", countryCode, Field.Store.YES)); - doc.add(new StringField("country_name", countryName, Field.Store.YES)); - doc.add(new StringField("street_address", streetAddress, Field.Store.YES)); + doc.add(new TextField("short_name", shortName, Field.Store.YES)); + doc.add(new TextField("display_name", displayName, Field.Store.YES)); + doc.add(new TextField("city_short_name", cityShortName, Field.Store.YES)); + doc.add(new TextField("city_name", cityName, Field.Store.YES)); + doc.add(new TextField("country_code", countryCode, Field.Store.YES)); + doc.add(new TextField("country_name", countryName, Field.Store.YES)); + doc.add(new TextField("street_address", streetAddress, Field.Store.YES)); doc.add(new DoublePoint("latitude_point", latitude.doubleValue())); doc.add(new StoredField("latitude", latitude.doubleValue())); doc.add(new DoublePoint("longitude_point", longitude.doubleValue())); diff --git a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymIndexSearcher.java b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/index/GymIndexSearcher.java similarity index 97% rename from gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymIndexSearcher.java rename to gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/index/GymIndexSearcher.java index 5f8e313..05d9802 100644 --- a/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/GymIndexSearcher.java +++ b/gymboard-search/src/main/java/nl/andrewlalis/gymboardsearch/index/GymIndexSearcher.java @@ -1,4 +1,4 @@ -package nl.andrewlalis.gymboardsearch; +package nl.andrewlalis.gymboardsearch.index; import nl.andrewlalis.gymboardsearch.dto.GymResponse; import org.apache.lucene.document.Document;