Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
ca64ef4e
Commit
ca64ef4e
authored
Apr 28, 2017
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1742: Provide option to exclude deleted entities in basic and fulltext search
parent
19d344cd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
10 deletions
+35
-10
AtlasDiscoveryService.java
...ava/org/apache/atlas/discovery/AtlasDiscoveryService.java
+4
-2
EntityDiscoveryService.java
...va/org/apache/atlas/discovery/EntityDiscoveryService.java
+25
-5
DiscoveryREST.java
...rc/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+6
-3
No files found.
repository/src/main/java/org/apache/atlas/discovery/AtlasDiscoveryService.java
View file @
ca64ef4e
...
@@ -35,11 +35,12 @@ public interface AtlasDiscoveryService {
...
@@ -35,11 +35,12 @@ public interface AtlasDiscoveryService {
/**
/**
*
*
* @param query search query.
* @param query search query.
* @param excludeDeletedEntities exclude deleted entities in search result.
* @param limit number of resultant rows (for pagination). [ limit > 0 ] and [ limit < maxlimit ]. -1 maps to atlas.search.defaultlimit property.
* @param limit number of resultant rows (for pagination). [ limit > 0 ] and [ limit < maxlimit ]. -1 maps to atlas.search.defaultlimit property.
* @param offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0.
* @param offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0.
* @return AtlasSearchResult
* @return AtlasSearchResult
*/
*/
AtlasSearchResult
searchUsingFullTextQuery
(
String
query
,
int
limit
,
int
offset
)
throws
AtlasBaseException
;
AtlasSearchResult
searchUsingFullTextQuery
(
String
query
,
boolean
excludeDeletedEntities
,
int
limit
,
int
offset
)
throws
AtlasBaseException
;
/**
/**
*
*
...
@@ -48,10 +49,11 @@ public interface AtlasDiscoveryService {
...
@@ -48,10 +49,11 @@ public interface AtlasDiscoveryService {
* @param classification classification name.
* @param classification classification name.
* @param attrName attribute name.
* @param attrName attribute name.
* @param attrValuePrefix attribute value prefix.
* @param attrValuePrefix attribute value prefix.
* @param excludeDeletedEntities exclude deleted entities in search result.
* @param limit number of resultant rows (for pagination). [ limit > 0 ] and [ limit < maxlimit ]. -1 maps to atlas.search.defaultlimit property.
* @param limit number of resultant rows (for pagination). [ limit > 0 ] and [ limit < maxlimit ]. -1 maps to atlas.search.defaultlimit property.
* @param offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0.
* @param offset offset to the results returned (for pagination). [ offset >= 0 ]. -1 maps to offset 0.
* @return AtlasSearchResult
* @return AtlasSearchResult
*/
*/
AtlasSearchResult
searchUsingBasicQuery
(
String
query
,
String
type
,
String
classification
,
String
attrName
,
AtlasSearchResult
searchUsingBasicQuery
(
String
query
,
String
type
,
String
classification
,
String
attrName
,
String
attrValuePrefix
,
int
limit
,
int
offset
)
throws
AtlasBaseException
;
String
attrValuePrefix
,
boolean
excludeDeletedEntities
,
int
limit
,
int
offset
)
throws
AtlasBaseException
;
}
}
repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
View file @
ca64ef4e
...
@@ -25,6 +25,7 @@ import org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult;
...
@@ -25,6 +25,7 @@ import org.apache.atlas.model.discovery.AtlasSearchResult.AttributeSearchResult;
import
org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
;
import
org.apache.atlas.discovery.graph.DefaultGraphPersistenceStrategy
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.instance.AtlasEntity.Status
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.model.instance.AtlasEntityHeader
;
import
org.apache.atlas.query.Expressions.AliasExpression
;
import
org.apache.atlas.query.Expressions.AliasExpression
;
import
org.apache.atlas.query.Expressions.Expression
;
import
org.apache.atlas.query.Expressions.Expression
;
...
@@ -46,7 +47,6 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
...
@@ -46,7 +47,6 @@ import org.apache.atlas.repository.graphdb.AtlasVertex;
import
org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever
;
import
org.apache.atlas.repository.store.graph.v1.EntityGraphRetriever
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasStructType
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasStructType.AtlasAttribute
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.util.AtlasGremlinQueryProvider
;
import
org.apache.atlas.util.AtlasGremlinQueryProvider
;
...
@@ -145,7 +145,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -145,7 +145,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
}
}
@Override
@Override
public
AtlasSearchResult
searchUsingFullTextQuery
(
String
fullTextQuery
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
public
AtlasSearchResult
searchUsingFullTextQuery
(
String
fullTextQuery
,
boolean
excludeDeletedEntities
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
fullTextQuery
,
AtlasQueryType
.
FULL_TEXT
);
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
fullTextQuery
,
AtlasQueryType
.
FULL_TEXT
);
QueryParams
params
=
validateSearchParams
(
limit
,
offset
);
QueryParams
params
=
validateSearchParams
(
limit
,
offset
);
AtlasIndexQuery
idxQuery
=
toAtlasIndexQuery
(
fullTextQuery
);
AtlasIndexQuery
idxQuery
=
toAtlasIndexQuery
(
fullTextQuery
);
...
@@ -153,14 +154,16 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -153,14 +154,16 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Executing Full text query: {}"
,
fullTextQuery
);
LOG
.
debug
(
"Executing Full text query: {}"
,
fullTextQuery
);
}
}
ret
.
setFullTextResult
(
getIndexQueryResults
(
idxQuery
,
params
));
ret
.
setFullTextResult
(
getIndexQueryResults
(
idxQuery
,
params
,
excludeDeletedEntities
));
return
ret
;
return
ret
;
}
}
@Override
@Override
public
AtlasSearchResult
searchUsingBasicQuery
(
String
query
,
String
typeName
,
String
classification
,
String
attrName
,
public
AtlasSearchResult
searchUsingBasicQuery
(
String
query
,
String
typeName
,
String
classification
,
String
attrName
,
String
attrValuePrefix
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
String
attrValuePrefix
,
boolean
excludeDeletedEntities
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
AtlasQueryType
.
BASIC
);
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
AtlasQueryType
.
BASIC
);
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
...
@@ -267,6 +270,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -267,6 +270,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
}
}
}
}
if
(
skipDeletedEntities
(
excludeDeletedEntities
,
vertex
))
{
continue
;
}
resultIdx
++;
resultIdx
++;
if
(
resultIdx
<=
startIdx
)
{
if
(
resultIdx
<=
startIdx
)
{
...
@@ -314,6 +321,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -314,6 +321,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
if
(
firstElement
instanceof
AtlasVertex
)
{
if
(
firstElement
instanceof
AtlasVertex
)
{
for
(
Object
element
:
queryResult
)
{
for
(
Object
element
:
queryResult
)
{
if
(
element
instanceof
AtlasVertex
)
{
if
(
element
instanceof
AtlasVertex
)
{
if
(
skipDeletedEntities
(
excludeDeletedEntities
,
(
AtlasVertex
)
element
))
{
continue
;
}
ret
.
addEntity
(
entityRetriever
.
toAtlasEntityHeader
((
AtlasVertex
)
element
));
ret
.
addEntity
(
entityRetriever
.
toAtlasEntityHeader
((
AtlasVertex
)
element
));
}
else
{
}
else
{
LOG
.
warn
(
"searchUsingBasicQuery({}): expected an AtlasVertex; found unexpected entry in result {}"
,
basicQuery
,
element
);
LOG
.
warn
(
"searchUsingBasicQuery({}): expected an AtlasVertex; found unexpected entry in result {}"
,
basicQuery
,
element
);
...
@@ -331,13 +342,18 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -331,13 +342,18 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
return
ret
;
return
ret
;
}
}
private
List
<
AtlasFullTextResult
>
getIndexQueryResults
(
AtlasIndexQuery
query
,
QueryParams
params
)
throws
AtlasBaseException
{
private
List
<
AtlasFullTextResult
>
getIndexQueryResults
(
AtlasIndexQuery
query
,
QueryParams
params
,
boolean
excludeDeletedEntities
)
throws
AtlasBaseException
{
List
<
AtlasFullTextResult
>
ret
=
new
ArrayList
<>();
List
<
AtlasFullTextResult
>
ret
=
new
ArrayList
<>();
Iterator
<
Result
>
iter
=
query
.
vertices
();
Iterator
<
Result
>
iter
=
query
.
vertices
();
while
(
iter
.
hasNext
()
&&
ret
.
size
()
<
params
.
limit
())
{
while
(
iter
.
hasNext
()
&&
ret
.
size
()
<
params
.
limit
())
{
Result
idxQueryResult
=
iter
.
next
();
Result
idxQueryResult
=
iter
.
next
();
AtlasVertex
vertex
=
idxQueryResult
.
getVertex
();
AtlasVertex
vertex
=
idxQueryResult
.
getVertex
();
if
(
skipDeletedEntities
(
excludeDeletedEntities
,
vertex
))
{
continue
;
}
String
guid
=
vertex
!=
null
?
vertex
.
getProperty
(
Constants
.
GUID_PROPERTY_KEY
,
String
.
class
)
:
null
;
String
guid
=
vertex
!=
null
?
vertex
.
getProperty
(
Constants
.
GUID_PROPERTY_KEY
,
String
.
class
)
:
null
;
if
(
guid
!=
null
)
{
if
(
guid
!=
null
)
{
...
@@ -422,4 +438,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -422,4 +438,8 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
return
ret
;
return
ret
;
}
}
private
boolean
skipDeletedEntities
(
boolean
excludeDeletedEntities
,
AtlasVertex
<?,
?>
vertex
)
{
return
excludeDeletedEntities
&&
GraphHelper
.
getStatus
(
vertex
)
==
Status
.
DELETED
;
}
}
}
webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
View file @
ca64ef4e
...
@@ -114,6 +114,7 @@ public class DiscoveryREST {
...
@@ -114,6 +114,7 @@ public class DiscoveryREST {
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
AtlasSearchResult
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
public
AtlasSearchResult
searchUsingFullText
(
@QueryParam
(
"query"
)
String
query
,
@QueryParam
(
"excludeDeletedEntities"
)
boolean
excludeDeletedEntities
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
AtlasPerfTracer
perf
=
null
;
AtlasPerfTracer
perf
=
null
;
...
@@ -124,7 +125,7 @@ public class DiscoveryREST {
...
@@ -124,7 +125,7 @@ public class DiscoveryREST {
limit
+
","
+
offset
+
")"
);
limit
+
","
+
offset
+
")"
);
}
}
return
atlasDiscoveryService
.
searchUsingFullTextQuery
(
query
,
limit
,
offset
);
return
atlasDiscoveryService
.
searchUsingFullTextQuery
(
query
,
excludeDeletedEntities
,
limit
,
offset
);
}
finally
{
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
AtlasPerfTracer
.
log
(
perf
);
}
}
...
@@ -150,6 +151,7 @@ public class DiscoveryREST {
...
@@ -150,6 +151,7 @@ public class DiscoveryREST {
public
AtlasSearchResult
searchUsingBasic
(
@QueryParam
(
"query"
)
String
query
,
public
AtlasSearchResult
searchUsingBasic
(
@QueryParam
(
"query"
)
String
query
,
@QueryParam
(
"typeName"
)
String
typeName
,
@QueryParam
(
"typeName"
)
String
typeName
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"excludeDeletedEntities"
)
boolean
excludeDeletedEntities
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
AtlasPerfTracer
perf
=
null
;
AtlasPerfTracer
perf
=
null
;
...
@@ -160,7 +162,8 @@ public class DiscoveryREST {
...
@@ -160,7 +162,8 @@ public class DiscoveryREST {
typeName
+
","
+
classification
+
","
+
limit
+
","
+
offset
+
")"
);
typeName
+
","
+
classification
+
","
+
limit
+
","
+
offset
+
")"
);
}
}
return
atlasDiscoveryService
.
searchUsingBasicQuery
(
query
,
typeName
,
classification
,
null
,
null
,
limit
,
offset
);
return
atlasDiscoveryService
.
searchUsingBasicQuery
(
query
,
typeName
,
classification
,
null
,
null
,
excludeDeletedEntities
,
limit
,
offset
);
}
finally
{
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
AtlasPerfTracer
.
log
(
perf
);
}
}
...
@@ -201,7 +204,7 @@ public class DiscoveryREST {
...
@@ -201,7 +204,7 @@ public class DiscoveryREST {
String
.
format
(
"attrName : {0}, attrValue: {1} for attribute search."
,
attrName
,
attrValuePrefix
));
String
.
format
(
"attrName : {0}, attrValue: {1} for attribute search."
,
attrName
,
attrValuePrefix
));
}
}
return
atlasDiscoveryService
.
searchUsingBasicQuery
(
null
,
typeName
,
null
,
attrName
,
attrValuePrefix
,
limit
,
offset
);
return
atlasDiscoveryService
.
searchUsingBasicQuery
(
null
,
typeName
,
null
,
attrName
,
attrValuePrefix
,
true
,
limit
,
offset
);
}
finally
{
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
AtlasPerfTracer
.
log
(
perf
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment