Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the KeywordAnalyzer to skip analysis on the subsequent page #10

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion forage-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>forage</artifactId>
<groupId>com.livetheoogway.forage</groupId>
<version>1.0.10</version>
<version>1.0.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion forage-dropwizard-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>forage</artifactId>
<groupId>com.livetheoogway.forage</groupId>
<version>1.0.10</version>
<version>1.0.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import io.dropwizard.lifecycle.Managed;
import io.dropwizard.setup.Environment;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.lucene.analysis.Analyzer;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -64,6 +66,10 @@ public ForageSearchEngine<D> searchEngine() {
return delegatedForageSearchEngine;
}

public Analyzer analyser() {
return null;
}

/**
* Use this to do adhoc {@link UpdateEngine#bootstrap()}, other than the periodic bootstrap that happens as part
* of this bundle.
Expand All @@ -80,11 +86,15 @@ public void run(final T configuration, final Environment environment) {
@Override
public void start() {
log.info("[forage][startup] Starting the engine...");
final ForageSearchEngineBuilder<D> engineBuilder = ForageSearchEngineBuilder.<D>builder()
val engineBuilder = ForageSearchEngineBuilder.<D>builder()
.withObjectMapper(environment.getObjectMapper())
.withDataStore(dataStore(configuration));
val analyser = analyser();
if (analyser != null) {
engineBuilder.withAnalyser(analyser);
}

final ForageEngineIndexer<D> forageEngineIndexer = new ForageEngineIndexer<>(engineBuilder);
val forageEngineIndexer = new ForageEngineIndexer<>(engineBuilder);

delegatedForageSearchEngine.onStart(forageEngineIndexer);

Expand Down
2 changes: 1 addition & 1 deletion forage-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>forage</artifactId>
<groupId>com.livetheoogway.forage</groupId>
<version>1.0.10</version>
<version>1.0.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
9 changes: 7 additions & 2 deletions forage-search-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<parent>
<artifactId>forage</artifactId>
<groupId>com.livetheoogway.forage</groupId>
<version>1.0.10</version>
<version>1.0.11</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>forage-search-engine</artifactId>

<properties>
<lucene.version>9.1.0</lucene.version>
<lucene-analyzers-common.version>8.11.2</lucene-analyzers-common.version>
<slf4j.version>1.7.25</slf4j.version>

</properties>

<dependencies>
Expand All @@ -33,6 +33,11 @@
<artifactId>lucene-queryparser</artifactId>
<version>${lucene.version}</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>${lucene-analyzers-common.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordAnalyzer;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.TopDocs;
Expand Down Expand Up @@ -79,7 +80,7 @@ public ForageLuceneSearchEngine(final ObjectMapper mapper,
this.luceneQueryGenerator = new LuceneQueryGenerator(analyzer, queryParserFactory);
this.lucenePagination = new LucenePagination(mapper);
this.dataStore = dataStore;
this.queryParser = new QueryParser("TEMP", analyzer); //todo needs a more elegant solution for page parsing
this.queryParser = new QueryParser("NO_FIELD", new KeywordAnalyzer()); //todo needs a more elegant solution for page parsing
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.livetheoogway.forage</groupId>
<artifactId>forage</artifactId>
<packaging>pom</packaging>
<version>1.0.10</version>
<version>1.0.11</version>

<name>forage</name>
<description>
Expand Down