This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new ea4e32d ATLAS-4108: updated free-text search processor to support
Elasticsearch
ea4e32d is described below
commit ea4e32d0657cbe5f161aa992578b0983636810ae
Author: Jarosław Cellary <[email protected]>
AuthorDate: Thu Jan 21 13:51:53 2021 +0100
ATLAS-4108: updated free-text search processor to support Elasticsearch
Signed-off-by: Madhan Neethiraj <[email protected]>
---
.../atlas/discovery/FreeTextSearchProcessor.java | 20 +++++++++++++++++++-
.../atlas/util/AtlasRepositoryConfiguration.java | 4 ----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git
a/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java
b/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java
index 56b514d..92152ff 100644
---
a/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java
+++
b/repository/src/main/java/org/apache/atlas/discovery/FreeTextSearchProcessor.java
@@ -17,6 +17,8 @@
*/
package org.apache.atlas.discovery;
+import org.apache.atlas.ApplicationProperties;
+import org.apache.atlas.AtlasException;
import org.apache.atlas.model.discovery.SearchParameters;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graph.GraphHelper;
@@ -41,6 +43,8 @@ public class FreeTextSearchProcessor extends SearchProcessor {
public static final String SOLR_QT_PARAMETER = "qt"; //
org.apache.solr.common.params.CommonParams.QT;
public static final String SOLR_REQUEST_HANDLER_NAME = "/freetext";
+ private static final boolean IS_SOLR_INDEX_BACKEND = isSolrIndexBackend();
+
private final AtlasIndexQuery indexQuery;
public FreeTextSearchProcessor(SearchContext context) {
@@ -70,7 +74,9 @@ public class FreeTextSearchProcessor extends SearchProcessor {
private GraphIndexQueryParameters
prepareGraphIndexQueryParameters(SearchContext context, StringBuilder
queryString) {
List<AtlasIndexQueryParameter> parameters = new ArrayList<>();
-
parameters.add(context.getGraph().indexQueryParameter(SOLR_QT_PARAMETER,
SOLR_REQUEST_HANDLER_NAME));
+ if (IS_SOLR_INDEX_BACKEND) {
+
parameters.add(context.getGraph().indexQueryParameter(SOLR_QT_PARAMETER,
SOLR_REQUEST_HANDLER_NAME));
+ }
return new GraphIndexQueryParameters(Constants.VERTEX_INDEX,
queryString.toString(), 0, parameters);
}
@@ -175,4 +181,16 @@ public class FreeTextSearchProcessor extends
SearchProcessor {
public long getResultCount() {
return indexQuery.vertexTotals();
}
+
+ private static boolean isSolrIndexBackend() {
+ try {
+ String indexBackEnd =
ApplicationProperties.get().getString(ApplicationProperties.INDEX_BACKEND_CONF);
+
+ return
ApplicationProperties.INDEX_BACKEND_SOLR.equalsIgnoreCase(indexBackEnd);
+ } catch (AtlasException e) {
+ LOG.error("Failed to get application property {}. Assuming Solr
index backend", ApplicationProperties.INDEX_BACKEND_SOLR, e);
+ }
+
+ return true; // default to Solr
+ }
}
diff --git
a/repository/src/main/java/org/apache/atlas/util/AtlasRepositoryConfiguration.java
b/repository/src/main/java/org/apache/atlas/util/AtlasRepositoryConfiguration.java
index c37d757..179fa43 100644
---
a/repository/src/main/java/org/apache/atlas/util/AtlasRepositoryConfiguration.java
+++
b/repository/src/main/java/org/apache/atlas/util/AtlasRepositoryConfiguration.java
@@ -253,10 +253,6 @@ public class AtlasRepositoryConfiguration {
try {
isFreeTextSearchEnabled =
ApplicationProperties.get().getBoolean(ApplicationProperties.ENABLE_FREETEXT_SEARCH_CONF,
true);
- if (isFreeTextSearchEnabled) { // currently free-text is
supported only for Solr
- isFreeTextSearchEnabled =
ApplicationProperties.INDEX_BACKEND_SOLR.equalsIgnoreCase(ApplicationProperties.get().getString(ApplicationProperties.INDEX_BACKEND_CONF));
- }
-
if (isFreeTextSearchEnabled) { // if free-text is enabled,
disable full-text - to avoid performance penalty
isFullTextSearchEnabled = false;
} else {