-
Notifications
You must be signed in to change notification settings - Fork 91
Elasticsearch 7.* and 8.* integration. OpenSearch integration. #469
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
Merged
litvinovg
merged 38 commits into
vivo-project:main
from
ivanmrsulja:feature/elasticsearch-integration
Dec 12, 2025
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
3723d73
Small mapping update and response parsing fix.
ivanmrsulja 951508b
Added query parser to transform Solr queries to ES JSON-like queries.
ivanmrsulja 987fa5c
Updated mapping to support aggregations.
ivanmrsulja 22a85e6
Added small ES query optimizations.
ivanmrsulja ee3fbb4
Completed implementation of missing ES engine methods. Improved docum…
ivanmrsulja b74091c
Switched to one search engine configuration URL. Implemented a server…
ivanmrsulja d46a80c
Added SSL and Basic auth support. Added OpenSearch support.
ivanmrsulja 84a822c
Added fallback configuration property for legacy Solr configurations.
ivanmrsulja a6b288a
Refactored code so that common property fallback resolution is in it'…
ivanmrsulja 789a23e
Fixed fetch count bug. Fixed advanced search filter bug where filter …
ivanmrsulja 1a4b269
Fixed facets query bug. Fixed delete by query bug.
ivanmrsulja db39bcc
Fixed UTF-8 parsing bug while indexing.
ivanmrsulja 991d06c
Added support for *_drsim fields. Fixed pagination and statistics bug.
ivanmrsulja 162a03e
Fixed sort by relevance bug.
ivanmrsulja b6fbaf2
Updated documentation.
ivanmrsulja a1fd76c
Updated example.runtime.properties
ivanmrsulja 829a0e6
Fixed inaccurate count retrieved for large indexes when using search …
ivanmrsulja b5b7383
Added field mappings which were missing for autocomplete search.
ivanmrsulja 03d74b9
Small bugfix and code refactor.
ivanmrsulja 6c0cd8b
Fixed sorting issue.
ivanmrsulja f95843d
Fixed match all query bug.
ivanmrsulja d346d22
Added support for aggregation (facet) search.
ivanmrsulja d11b311
Added support for facet browsing functionality. Added support for reg…
ivanmrsulja 023e53f
Fixed date range slider issue.
ivanmrsulja 7e01a57
Implemented a linear pass experimental fix to parsing problems.
ivanmrsulja ba5387a
Fixed all query parsing issues.
ivanmrsulja b008651
Updated lucene dependencies to latest supported version.
ivanmrsulja 8859e76
Added search controller flag for treating input as simple text. Fixed…
ivanmrsulja c323406
Small cleanup.
ivanmrsulja 7d8c893
Merge branch 'main' into feature/elasticsearch-integration
ivanmrsulja deee6c0
Faceted filter fix.
ivanmrsulja 41098af
Fixed empty field edgecase.
ivanmrsulja 70b6df8
Small fix to apply edgecase in situations where controller is called …
ivanmrsulja 43211ad
Added tests. Cleaned up code.
ivanmrsulja f64040f
Renamed few getters and setters to align with naming convention.
ivanmrsulja 15d2098
Small optimisation and variable renaming to align to naming convention.
ivanmrsulja 4dacb92
Enchanced HTTP/HTTPS ES integration infrastructure with optional basi…
ivanmrsulja 00e1210
Certificate trust level bugfix.
ivanmrsulja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
api/src/main/java/edu/cornell/mannlib/vitro/webapp/searchengine/base/SearchEngineUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package edu.cornell.mannlib.vitro.webapp.searchengine.base; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| import javax.annotation.Nullable; | ||
|
|
||
| import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; | ||
| import org.apache.commons.logging.Log; | ||
| import org.apache.commons.logging.LogFactory; | ||
|
|
||
| public class SearchEngineUtil { | ||
|
|
||
| private static final Log log = LogFactory.getLog(SearchEngineUtil.class); | ||
|
|
||
| @Nullable | ||
| public static String getSearchEngineURLProperty() { | ||
| ConfigurationProperties config = ConfigurationProperties.getInstance(); | ||
| if (Objects.isNull(config)) { | ||
| return null; | ||
| } | ||
|
|
||
| if (config.getProperty("vitro.local.searchengine.url", "").isEmpty()) { | ||
| return tryFetchLegacySolrConfiguration(config); | ||
| } | ||
|
|
||
| return config.getProperty("vitro.local.searchengine.url", ""); | ||
| } | ||
|
|
||
| private static String tryFetchLegacySolrConfiguration(ConfigurationProperties config) { | ||
| String legacyConfigValue = config.getProperty("vitro.local.solr.url", ""); | ||
| if (!legacyConfigValue.isEmpty()) { | ||
| log.warn( | ||
| "vitro.local.solr.url is deprecated, switch to using" + | ||
| " vitro.local.searchengine.url as soon as possible."); | ||
| } | ||
|
|
||
| return legacyConfigValue; | ||
| } | ||
| } | ||
95 changes: 95 additions & 0 deletions
95
.../java/edu/cornell/mannlib/vitro/webapp/searchengine/elasticsearch/CustomQueryBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package edu.cornell.mannlib.vitro.webapp.searchengine.elasticsearch; | ||
|
|
||
| import co.elastic.clients.elasticsearch._types.query_dsl.ExistsQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.FuzzyQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.MatchAllQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.MatchPhraseQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.MatchQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.PrefixQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.Query; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.RangeQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.RegexpQuery; | ||
| import co.elastic.clients.elasticsearch._types.query_dsl.WildcardQuery; | ||
|
|
||
| public class CustomQueryBuilder { | ||
|
|
||
| private static final String MAX_FUZZY_EDITS = "2"; | ||
|
|
||
| private CustomQueryBuilder() { | ||
| } | ||
|
|
||
|
|
||
| public static Query buildQuery(SearchType queryType, String field, String value) { | ||
|
ivanmrsulja marked this conversation as resolved.
|
||
| validateInput(field, value); | ||
|
|
||
| switch (queryType) { | ||
| case MATCH: | ||
| return MatchQuery.of(m -> m | ||
| .field(field) | ||
| .query(value) | ||
| )._toQuery(); | ||
| case FUZZY: | ||
| return FuzzyQuery.of(m -> m | ||
| .field(field) | ||
| .value(value.replace("~", "")) | ||
| .fuzziness(MAX_FUZZY_EDITS) | ||
| )._toQuery(); | ||
| case PREFIX: | ||
| return PrefixQuery.of(m -> m | ||
| .field(field) | ||
| .value(value) | ||
| )._toQuery(); | ||
| case RANGE: | ||
| String[] values = value.split("TO"); | ||
| return RangeQuery.of(m -> m | ||
| .field(field) | ||
| .from(values[0].replace("[", "").replace("(", "").trim()) | ||
| .to(values[1].replace("]", "").replace(")", "").trim()) | ||
| )._toQuery(); | ||
| case EXISTS: | ||
| return ExistsQuery.of(m -> m | ||
| .field(field) | ||
| )._toQuery(); | ||
| case MATCH_ALL: | ||
| return MatchAllQuery.of(m -> m)._toQuery(); | ||
| case REGEXP: | ||
| String regexpValue; | ||
|
|
||
| boolean isSolrRegexpSpecification = value.startsWith("/") && value.endsWith("/") && value.length() > 1; | ||
| if (isSolrRegexpSpecification) { | ||
| regexpValue = value.substring(1, value.length() - 1); | ||
| } else { | ||
| regexpValue = value; | ||
| } | ||
|
|
||
| return RegexpQuery.of(m -> m | ||
| .field(field) | ||
| .value(regexpValue) | ||
| )._toQuery(); | ||
| case WILDCARD: | ||
| if (field.trim().equals("*")) { | ||
| return MatchAllQuery.of(m -> m)._toQuery(); | ||
| } | ||
|
|
||
| return WildcardQuery.of(m -> m | ||
| .field(field) | ||
| .value(value.replace(".*", "*")) | ||
| )._toQuery(); | ||
| default: | ||
| return MatchPhraseQuery.of(m -> m | ||
| .field(field) | ||
| .query(value.length() > 1 ? value.substring(1, value.length() - 1) : value) | ||
| // Remove leading and trailing '"' character | ||
| )._toQuery(); | ||
| } | ||
| } | ||
|
|
||
| private static void validateInput(String field, String value) { | ||
| if (field == null || field.isEmpty()) { | ||
| throw new IllegalArgumentException("Field not specified"); | ||
| } | ||
| if (value == null) { | ||
| throw new IllegalArgumentException("Value not specified"); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.