Commit 64c9bde6 by Madhan Neethiraj

ATLAS-2082: basic-search fails when in-memory filters all results from index-query

parent bb189766
......@@ -236,22 +236,23 @@ public class ClassificationSearchProcessor extends SearchProcessor {
// Now filter on the tag attributes
Set<String> guids = getGuids(entityVertices);
gremlinQueryBindings.put("guids", guids);
// Clear prior results
entityVertices.clear();
try {
AtlasGraph graph = context.getGraph();
ScriptEngine gremlinScriptEngine = graph.getGremlinScriptEngine();
List<AtlasVertex> atlasVertices = (List<AtlasVertex>) graph.executeGremlinScript(gremlinScriptEngine, gremlinQueryBindings, gremlinTagFilterQuery, false);
if (CollectionUtils.isNotEmpty(guids)) {
gremlinQueryBindings.put("guids", guids);
// Clear prior results
entityVertices.clear();
try {
AtlasGraph graph = context.getGraph();
ScriptEngine gremlinScriptEngine = graph.getGremlinScriptEngine();
List<AtlasVertex> atlasVertices = (List<AtlasVertex>) graph.executeGremlinScript(gremlinScriptEngine, gremlinQueryBindings, gremlinTagFilterQuery, false);
if (CollectionUtils.isNotEmpty(atlasVertices)) {
entityVertices.addAll(atlasVertices);
if (CollectionUtils.isNotEmpty(atlasVertices)) {
entityVertices.addAll(atlasVertices);
}
} catch (AtlasBaseException | ScriptException e) {
LOG.warn(e.getMessage(), e);
}
} catch (AtlasBaseException | ScriptException e) {
LOG.warn(e.getMessage(), e);
}
}
......
......@@ -173,12 +173,17 @@ public class EntitySearchProcessor extends SearchProcessor {
CollectionUtils.filter(entityVertices, inMemoryPredicate);
if (graphQuery != null) {
AtlasGraphQuery guidQuery = context.getGraph().query().in(Constants.GUID_PROPERTY_KEY, getGuids(entityVertices));
guidQuery.addConditionsFrom(graphQuery);
Set<String> guids = getGuids(entityVertices);
entityVertices.clear();
getVertices(guidQuery.vertices().iterator(), entityVertices);
if (CollectionUtils.isNotEmpty(guids)) {
AtlasGraphQuery guidQuery = context.getGraph().query().in(Constants.GUID_PROPERTY_KEY, guids);
guidQuery.addConditionsFrom(graphQuery);
getVertices(guidQuery.vertices().iterator(), entityVertices);
}
}
} else {
Iterator<AtlasVertex> queryResult = graphQuery.vertices(qryOffset, limit).iterator();
......@@ -211,12 +216,17 @@ public class EntitySearchProcessor extends SearchProcessor {
LOG.debug("==> EntitySearchProcessor.filter({})", entityVertices.size());
}
AtlasGraphQuery query = context.getGraph().query().in(Constants.GUID_PROPERTY_KEY, getGuids(entityVertices));
query.addConditionsFrom(filterGraphQuery);
Set<String> guids = getGuids(entityVertices);
entityVertices.clear();
getVertices(query.vertices().iterator(), entityVertices);
if (CollectionUtils.isNotEmpty(guids)) {
AtlasGraphQuery query = context.getGraph().query().in(Constants.GUID_PROPERTY_KEY, guids);
query.addConditionsFrom(filterGraphQuery);
getVertices(query.vertices().iterator(), entityVertices);
}
super.filter(entityVertices);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment