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
d30fa2c2
Commit
d30fa2c2
authored
Apr 03, 2017
by
Sarath Subramanian
Committed by
Madhan Neethiraj
Apr 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1761: improve attribute search to enable search based on display text
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
c4fc5b4f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
14 deletions
+43
-14
EntityDiscoveryService.java
...va/org/apache/atlas/discovery/EntityDiscoveryService.java
+38
-12
AtlasGremlin2QueryProvider.java
...ava/org/apache/atlas/util/AtlasGremlin2QueryProvider.java
+2
-0
AtlasGremlinQueryProvider.java
...java/org/apache/atlas/util/AtlasGremlinQueryProvider.java
+2
-1
DiscoveryREST.java
...rc/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
+1
-1
No files found.
repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
View file @
d30fa2c2
...
...
@@ -64,6 +64,7 @@ import javax.inject.Inject;
import
javax.script.ScriptEngine
;
import
javax.script.ScriptException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -199,34 +200,53 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
ret
.
setClassification
(
classification
);
}
boolean
isAttributeSearch
=
StringUtils
.
isNotEmpty
(
attrName
)
&&
StringUtils
.
isNotEmpty
(
attrValuePrefix
);
boolean
isAttributeSearch
=
StringUtils
.
isNotEmpty
(
attrName
)
||
StringUtils
.
isNotEmpty
(
attrValuePrefix
);
boolean
isGuidPrefixSearch
=
false
;
if
(
isAttributeSearch
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Executing attribute search attrName: {} and attrValue: {}"
,
attrName
,
attrValuePrefix
);
}
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
ret
.
setQueryType
(
AtlasQueryType
.
ATTRIBUTE
);
if
(
entityType
!=
null
)
{
AtlasAttribute
attribute
=
entityType
.
getAttribute
(
attrName
);
AtlasAttribute
attribute
=
null
;
if
(
StringUtils
.
isNotEmpty
(
attrName
))
{
attribute
=
entityType
.
getAttribute
(
attrName
);
if
(
attribute
==
null
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_ATTRIBUTE
,
attrName
,
typeName
);
}
attrQualifiedName
=
entityType
.
getAttribute
(
attrName
).
getQualifiedName
();
}
else
{
// if attrName is null|empty iterate defaultAttrNames to get attribute value
final
List
<
String
>
defaultAttrNames
=
new
ArrayList
<>(
Arrays
.
asList
(
"qualifiedName"
,
"name"
));
Iterator
<
String
>
iter
=
defaultAttrNames
.
iterator
();
while
(
iter
.
hasNext
()
&&
attribute
==
null
)
{
attrName
=
iter
.
next
();
attribute
=
entityType
.
getAttribute
(
attrName
);
}
}
String
attrQuery
=
String
.
format
(
"%s AND (%s *)"
,
attrName
,
attrValuePrefix
.
replaceAll
(
"\\."
,
" "
));
if
(
attribute
==
null
)
{
// for guid prefix search use gremlin and nullify query to avoid using fulltext
// (guids cannot be searched in fulltext)
isGuidPrefixSearch
=
true
;
query
=
null
;
if
(
StringUtils
.
isEmpty
(
query
))
{
query
=
attrQuery
;
}
else
{
query
=
String
.
format
(
"(%s) AND (%s)"
,
query
,
attrQuery
);
attrQualifiedName
=
attribute
.
getQualifiedName
();
String
attrQuery
=
String
.
format
(
"%s AND (%s *)"
,
attrName
,
attrValuePrefix
.
replaceAll
(
"\\."
,
" "
));
query
=
StringUtils
.
isEmpty
(
query
)
?
attrQuery
:
String
.
format
(
"(%s) AND (%s)"
,
query
,
attrQuery
);
}
}
ret
.
setQueryType
(
AtlasQueryType
.
ATTRIBUTE
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Executing attribute search attrName: {} and attrValue: {}"
,
attrName
,
attrValuePrefix
);
}
}
// if query was provided, perform indexQuery and filter for typeName & classification in memory; this approach
...
...
@@ -304,6 +324,12 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
basicQuery
+=
gremlinQueryProvider
.
getQuery
(
AtlasGremlinQuery
.
BASIC_SEARCH_TYPE_FILTER
);
}
if
(
isGuidPrefixSearch
)
{
bindings
.
put
(
"guid"
,
attrValuePrefix
+
".*"
);
basicQuery
+=
gremlinQueryProvider
.
getQuery
(
AtlasGremlinQuery
.
GUID_PREFIX_FILTER
);
}
bindings
.
put
(
"startIdx"
,
params
.
offset
());
bindings
.
put
(
"endIdx"
,
params
.
offset
()
+
params
.
limit
());
...
...
repository/src/main/java/org/apache/atlas/util/AtlasGremlin2QueryProvider.java
View file @
d30fa2c2
...
...
@@ -71,6 +71,8 @@ public class AtlasGremlin2QueryProvider extends AtlasGremlinQueryProvider {
return
".has('__traitNames', T.in, traitNames)"
;
case
TO_RANGE_LIST:
return
" [startIdx..<endIdx].toList()"
;
case
GUID_PREFIX_FILTER:
return
".filter{it.'__guid'.matches(guid)}"
;
}
// Should never reach this point
return
null
;
...
...
repository/src/main/java/org/apache/atlas/util/AtlasGremlinQueryProvider.java
View file @
d30fa2c2
...
...
@@ -58,6 +58,7 @@ public abstract class AtlasGremlinQueryProvider {
// Discovery Queries
BASIC_SEARCH_TYPE_FILTER
,
BASIC_SEARCH_CLASSIFICATION_FILTER
,
TO_RANGE_LIST
TO_RANGE_LIST
,
GUID_PREFIX_FILTER
}
}
webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java
View file @
d30fa2c2
...
...
@@ -199,7 +199,7 @@ public class DiscoveryREST {
attrValuePrefix
+
","
+
typeName
+
","
+
limit
+
","
+
offset
+
")"
);
}
if
(
StringUtils
.
isEmpty
(
attrName
)
||
StringUtils
.
isEmpty
(
attrValuePrefix
))
{
if
(
StringUtils
.
isEmpty
(
attrName
)
&&
StringUtils
.
isEmpty
(
attrValuePrefix
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_PARAMETERS
,
String
.
format
(
"attrName : {0}, attrValue: {1} for attribute search."
,
attrName
,
attrValuePrefix
));
}
...
...
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