Skip to content

Commit

Permalink
Merge pull request #80 from Yorubaname/removing-elastic-search
Browse files Browse the repository at this point in the history
Make search pluggable.
  • Loading branch information
dadepo authored Dec 20, 2017
2 parents 15f8f0b + 8bfaf88 commit 63ed490
Show file tree
Hide file tree
Showing 28 changed files with 530 additions and 249 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,36 @@ when starting the application. For example:
Remember this command needs to be run from the website module, that is `{parent_directory}/website` directory.
### Search functionality
The search API is defined in the `searchapi` module. We currently have two implementations for the search api:
1. ElasticSearch - Implemented in the `elasticsearch-module` module
2. JPA based search - Implemented in the `jpa-search-module` module
The `jpa-search-module` module is used in the `website` module which represents the website running at www.yorubaname.com
If you want to use `elasticsearch` module then remove the following section in the pom.xml for `website` module:
```
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jpa-search-module</artifactId>
<version>${project.version}</version>
</dependency>
```
with
```
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elasticsearch-module</artifactId>
<version>${project.version}</version>
</dependency>
```
The `elasticsearch-module` needs to be configured. This is explained in the next session.
### Configuring ElasticSearch Properties
The ElasticSearch module does not require the installation of ElasticSearch as it will run with an embedded ElasticSearch instance:
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elasticsearch-module</artifactId>
<artifactId>search-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Expand Down
20 changes: 10 additions & 10 deletions bootstrap/src/main/java/org/oruko/dictionary/util/DataImporter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.oruko.dictionary.util;

import org.oruko.dictionary.elasticsearch.ElasticSearchService;
import org.oruko.dictionary.model.GeoLocation;
import org.oruko.dictionary.model.NameEntry;
import org.oruko.dictionary.model.State;
Expand Down Expand Up @@ -30,9 +29,6 @@ public class DataImporter {
@Autowired
private GeoLocationRepository geoLocationRepository;

@Autowired
private ElasticSearchService elasticSearchService;

@Autowired
private NameEntryRepository nameEntryRepository;

Expand All @@ -49,7 +45,6 @@ public void initializeData() {
*/
if (host.equalsIgnoreCase("localhost")) {
List<NameEntry> nameEntries = initializeDb();
initializeElastic(nameEntries);
}
}

Expand Down Expand Up @@ -111,7 +106,15 @@ private List<NameEntry> initializeDb() {
bolanle.setExtendedMeaning("This is extended dummy meaning for Bọ́lánlé");
bolanle.setGeoLocation(Arrays.asList(new GeoLocation("IBADAN", "NWY")));
bolanle.setEtymology(etymology);
bolanle.setState(State.NEW);
bolanle.setState(State.PUBLISHED);


NameEntry bimpe = new NameEntry("Bimpe");
bimpe.setMeaning("This is dummy meaning for Bimpe");
bimpe.setExtendedMeaning("This is extended dummy meaning for Bimpe");
bimpe.setGeoLocation(Arrays.asList(new GeoLocation("IBADAN", "NWY")));
bimpe.setEtymology(etymology);
bimpe.setState(State.PUBLISHED);

NameEntry ade0 = new NameEntry("Ade");
ade0.setMeaning("This is dummy meaning for ade");
Expand Down Expand Up @@ -174,6 +177,7 @@ private List<NameEntry> initializeDb() {
nameEntryRepository.save(tola);
nameEntryRepository.save(dadepo);
nameEntryRepository.save(bolanle);
nameEntryRepository.save(bimpe);
nameEntryRepository.save(ade0);
nameEntryRepository.save(ade1);
nameEntryRepository.save(ade2);
Expand All @@ -186,10 +190,6 @@ private List<NameEntry> initializeDb() {
ade0, ade1, ade2, ade3, ade4, omowumi, omolabi);
}

private void initializeElastic(List<NameEntry> nameEntries) {
elasticSearchService.bulkIndexName(nameEntries);
}

private void initGeoLocation() {
// North-West Yoruba (NWY): Abẹokuta, Ibadan, Ọyọ, Ogun and Lagos (Eko) areas
// Central Yoruba (CY): Igbomina, Yagba, Ilésà, Ifẹ, Ekiti, Akurẹ, Ẹfọn, and Ijẹbu areas.
Expand Down
5 changes: 5 additions & 0 deletions elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
<artifactId>elasticsearch-module</artifactId>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>search-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.apache.lucene</groupId>
Expand Down
Loading

0 comments on commit 63ed490

Please sign in to comment.