Changed string fields to text fields.

This commit is contained in:
Andrew Lalis 2023-01-24 13:01:24 +01:00
parent 7090036736
commit 470842172c
4 changed files with 13 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package nl.andrewlalis.gymboardsearch; package nl.andrewlalis.gymboardsearch;
import nl.andrewlalis.gymboardsearch.index.GymIndexGenerator;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,6 +1,7 @@
package nl.andrewlalis.gymboardsearch; package nl.andrewlalis.gymboardsearch;
import nl.andrewlalis.gymboardsearch.dto.GymResponse; 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.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;

View File

@ -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.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.*; import org.apache.lucene.document.*;
@ -24,7 +25,7 @@ import java.sql.ResultSet;
public class GymIndexGenerator { public class GymIndexGenerator {
private static final Logger log = LoggerFactory.getLogger(GymIndexGenerator.class); private static final Logger log = LoggerFactory.getLogger(GymIndexGenerator.class);
void generateIndex() throws Exception { public void generateIndex() throws Exception {
log.info("Starting Gym index generation."); log.info("Starting Gym index generation.");
Path gymIndexDir = Path.of("gym-index"); Path gymIndexDir = Path.of("gym-index");
FileSystemUtils.deleteRecursively(gymIndexDir); FileSystemUtils.deleteRecursively(gymIndexDir);
@ -51,13 +52,13 @@ public class GymIndexGenerator {
BigDecimal longitude = resultSet.getBigDecimal("longitude"); BigDecimal longitude = resultSet.getBigDecimal("longitude");
Document doc = new Document(); Document doc = new Document();
doc.add(new StringField("short_name", shortName, Field.Store.YES)); doc.add(new TextField("short_name", shortName, Field.Store.YES));
doc.add(new StringField("display_name", displayName, Field.Store.YES)); doc.add(new TextField("display_name", displayName, Field.Store.YES));
doc.add(new StringField("city_short_name", cityShortName, Field.Store.YES)); doc.add(new TextField("city_short_name", cityShortName, Field.Store.YES));
doc.add(new StringField("city_name", cityName, Field.Store.YES)); doc.add(new TextField("city_name", cityName, Field.Store.YES));
doc.add(new StringField("country_code", countryCode, Field.Store.YES)); doc.add(new TextField("country_code", countryCode, Field.Store.YES));
doc.add(new StringField("country_name", countryName, Field.Store.YES)); doc.add(new TextField("country_name", countryName, Field.Store.YES));
doc.add(new StringField("street_address", streetAddress, Field.Store.YES)); doc.add(new TextField("street_address", streetAddress, Field.Store.YES));
doc.add(new DoublePoint("latitude_point", latitude.doubleValue())); doc.add(new DoublePoint("latitude_point", latitude.doubleValue()));
doc.add(new StoredField("latitude", latitude.doubleValue())); doc.add(new StoredField("latitude", latitude.doubleValue()));
doc.add(new DoublePoint("longitude_point", longitude.doubleValue())); doc.add(new DoublePoint("longitude_point", longitude.doubleValue()));

View File

@ -1,4 +1,4 @@
package nl.andrewlalis.gymboardsearch; package nl.andrewlalis.gymboardsearch.index;
import nl.andrewlalis.gymboardsearch.dto.GymResponse; import nl.andrewlalis.gymboardsearch.dto.GymResponse;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;