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
670a4c00
Commit
670a4c00
authored
Mar 04, 2017
by
Sarath Subramanian
Committed by
Madhan Neethiraj
Mar 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1630: basic search implementation (#2)
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
2bbbd1a5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
2 deletions
+28
-2
AtlasSearchResult.java
...a/org/apache/atlas/model/discovery/AtlasSearchResult.java
+4
-0
EntityDiscoveryService.java
...va/org/apache/atlas/discovery/EntityDiscoveryService.java
+6
-1
DiscoveryREST.java
...rc/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+18
-1
No files found.
intg/src/main/java/org/apache/atlas/model/discovery/AtlasSearchResult.java
View file @
670a4c00
...
@@ -52,6 +52,10 @@ public class AtlasSearchResult implements Serializable {
...
@@ -52,6 +52,10 @@ public class AtlasSearchResult implements Serializable {
public
AtlasSearchResult
()
{}
public
AtlasSearchResult
()
{}
public
AtlasSearchResult
(
AtlasQueryType
queryType
)
{
this
(
null
,
queryType
);
}
public
AtlasSearchResult
(
String
queryText
,
AtlasQueryType
queryType
)
{
public
AtlasSearchResult
(
String
queryText
,
AtlasQueryType
queryType
)
{
setQueryText
(
queryText
);
setQueryText
(
queryText
);
setQueryType
(
queryType
);
setQueryType
(
queryType
);
...
...
repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
View file @
670a4c00
...
@@ -158,7 +158,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -158,7 +158,7 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
@Override
@Override
public
AtlasSearchResult
searchUsingBasicQuery
(
String
query
,
String
typeName
,
String
classification
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
public
AtlasSearchResult
searchUsingBasicQuery
(
String
query
,
String
typeName
,
String
classification
,
int
limit
,
int
offset
)
throws
AtlasBaseException
{
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
query
,
AtlasQueryType
.
BASIC
);
AtlasSearchResult
ret
=
new
AtlasSearchResult
(
AtlasQueryType
.
BASIC
);
if
(
LOG
.
isDebugEnabled
())
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Executing basic search query: {} with type: {} and classification: {}"
,
query
,
typeName
,
classification
);
LOG
.
debug
(
"Executing basic search query: {} with type: {} and classification: {}"
,
query
,
typeName
,
classification
);
...
@@ -197,7 +197,12 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
...
@@ -197,7 +197,12 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
ret
.
setClassification
(
classification
);
ret
.
setClassification
(
classification
);
}
}
if
(
StringUtils
.
isNotEmpty
(
query
))
{
basicQuery
+=
String
.
format
(
gremlinQueryProvider
.
getQuery
(
AtlasGremlinQuery
.
BASIC_SEARCH_QUERY_FILTER
),
query
);
basicQuery
+=
String
.
format
(
gremlinQueryProvider
.
getQuery
(
AtlasGremlinQuery
.
BASIC_SEARCH_QUERY_FILTER
),
query
);
ret
.
setQueryText
(
query
);
}
basicQuery
+=
String
.
format
(
gremlinQueryProvider
.
getQuery
(
AtlasGremlinQuery
.
TO_RANGE_LIST
),
params
.
offset
(),
params
.
limit
());
basicQuery
+=
String
.
format
(
gremlinQueryProvider
.
getQuery
(
AtlasGremlinQuery
.
TO_RANGE_LIST
),
params
.
offset
(),
params
.
limit
());
try
{
try
{
...
...
webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
View file @
670a4c00
...
@@ -21,6 +21,7 @@ import org.apache.atlas.exception.AtlasBaseException;
...
@@ -21,6 +21,7 @@ import org.apache.atlas.exception.AtlasBaseException;
import
org.apache.atlas.discovery.AtlasDiscoveryService
;
import
org.apache.atlas.discovery.AtlasDiscoveryService
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.model.discovery.AtlasSearchResult
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.commons.lang3.StringUtils
;
import
javax.inject.Inject
;
import
javax.inject.Inject
;
import
javax.inject.Singleton
;
import
javax.inject.Singleton
;
...
@@ -46,6 +47,8 @@ public class DiscoveryREST {
...
@@ -46,6 +47,8 @@ public class DiscoveryREST {
/**
/**
* Retrieve data for the specified DSL
* Retrieve data for the specified DSL
* @param query DSL query
* @param query DSL query
* @param type limit the result to only entities of specified type or its sub-types
* @param classification limit the result to only entities tagged with the given classification or or its sub-types
* @param limit limit the result set to only include the specified number of entries
* @param limit limit the result set to only include the specified number of entries
* @param offset start offset of the result set (useful for pagination)
* @param offset start offset of the result set (useful for pagination)
* @return Search results
* @return Search results
...
@@ -59,10 +62,24 @@ public class DiscoveryREST {
...
@@ -59,10 +62,24 @@ 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
searchUsingDSL
(
@QueryParam
(
"query"
)
String
query
,
public
AtlasSearchResult
searchUsingDSL
(
@QueryParam
(
"query"
)
String
query
,
@QueryParam
(
"type"
)
String
type
,
@QueryParam
(
"classification"
)
String
classification
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"limit"
)
int
limit
,
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
@QueryParam
(
"offset"
)
int
offset
)
throws
AtlasBaseException
{
String
queryStr
=
query
==
null
?
""
:
query
;
if
(
StringUtils
.
isNoneEmpty
(
type
))
{
queryStr
=
type
+
" "
+
queryStr
;
}
if
(
StringUtils
.
isNoneEmpty
(
classification
))
{
// isa works with a type name only - like hive_column isa PII; it doesn't work with more complex query
if
(
StringUtils
.
isEmpty
(
query
))
{
queryStr
+=
(
" isa "
+
classification
);
}
}
AtlasSearchResult
ret
=
atlasDiscoveryService
.
searchUsingDslQuery
(
query
,
limit
,
offset
);
AtlasSearchResult
ret
=
atlasDiscoveryService
.
searchUsingDslQuery
(
query
Str
,
limit
,
offset
);
return
ret
;
return
ret
;
}
}
...
...
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