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
62d85a4c
Commit
62d85a4c
authored
Jul 20, 2017
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1961: Basic search improvement in use of Solr index for attribute filtering (# 5)
parent
13ba156f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
18 deletions
+19
-18
EntitySearchProcessor.java
...ava/org/apache/atlas/discovery/EntitySearchProcessor.java
+0
-2
FullTextSearchProcessor.java
...a/org/apache/atlas/discovery/FullTextSearchProcessor.java
+4
-8
SearchProcessor.java
...main/java/org/apache/atlas/discovery/SearchProcessor.java
+15
-8
No files found.
repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
View file @
62d85a4c
...
...
@@ -18,10 +18,8 @@
package
org
.
apache
.
atlas
.
discovery
;
import
org.apache.atlas.model.discovery.SearchParameters.FilterCriteria
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graphdb.*
;
import
org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1
;
import
org.apache.atlas.type.AtlasClassificationType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
...
...
repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java
View file @
62d85a4c
...
...
@@ -20,12 +20,10 @@ package org.apache.atlas.discovery;
import
org.apache.atlas.model.discovery.SearchParameters
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.graphdb.AtlasIndexQuery
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
import
org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1
;
import
org.apache.atlas.utils.AtlasPerfTracer
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -55,7 +53,8 @@ public class FullTextSearchProcessor extends SearchProcessor {
Set
<
String
>
typeAndSubTypeNames
=
context
.
getEntityType
().
getTypeAndAllSubTypes
();
if
(
typeAndSubTypeNames
.
size
()
<=
MAX_ENTITY_TYPES_IN_INDEX_QUERY
)
{
queryString
.
append
(
AND_STR
).
append
(
"("
).
append
(
StringUtils
.
join
(
typeAndSubTypeNames
,
SPACE_STRING
)).
append
(
")"
);
queryString
.
append
(
AND_STR
);
appendIndexQueryValue
(
typeAndSubTypeNames
,
queryString
);
}
else
{
LOG
.
warn
(
"'{}' has too many subtypes ({}) to include in index-query; might cause poor performance"
,
context
.
getEntityType
().
getTypeName
(),
typeAndSubTypeNames
.
size
());
...
...
@@ -68,17 +67,14 @@ public class FullTextSearchProcessor extends SearchProcessor {
Set
<
String
>
typeAndSubTypeNames
=
context
.
getClassificationType
().
getTypeAndAllSubTypes
();
if
(
typeAndSubTypeNames
.
size
()
<=
MAX_CLASSIFICATION_TYPES_IN_INDEX_QUERY
)
{
queryString
.
append
(
AND_STR
).
append
(
"("
).
append
(
StringUtils
.
join
(
typeAndSubTypeNames
,
SPACE_STRING
)).
append
(
")"
);
queryString
.
append
(
AND_STR
);
appendIndexQueryValue
(
typeAndSubTypeNames
,
queryString
);
}
else
{
LOG
.
warn
(
"'{}' has too many subtypes ({}) to include in index-query; might cause poor performance"
,
context
.
getClassificationType
().
getTypeName
(),
typeAndSubTypeNames
.
size
());
}
}
if
(
context
.
getSearchParameters
().
getExcludeDeletedEntities
())
{
queryString
.
append
(
AND_STR
).
append
(
"(ACTIVE)"
);
}
queryString
.
append
(
")"
);
indexQuery
=
context
.
getGraph
().
indexQuery
(
Constants
.
FULLTEXT_INDEX
,
queryString
.
toString
());
...
...
repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
View file @
62d85a4c
...
...
@@ -48,12 +48,12 @@ public abstract class SearchProcessor {
public
static
final
String
AND_STR
=
" AND "
;
public
static
final
String
EMPTY_STRING
=
""
;
public
static
final
String
SPACE_STRING
=
" "
;
public
static
final
String
BRACE_OPEN_STR
=
"(
"
;
public
static
final
String
BRACE_CLOSE_STR
=
"
)"
;
public
static
final
String
BRACE_OPEN_STR
=
"("
;
public
static
final
String
BRACE_CLOSE_STR
=
")"
;
public
static
final
char
DOUBLE_QUOTE
=
'"'
;
private
static
final
Map
<
SearchParameters
.
Operator
,
String
>
OPERATOR_MAP
=
new
HashMap
<>();
private
static
final
char
[]
OFFENDING_CHARS
=
{
'@'
,
'/'
,
' '
};
// This can grow as we discover corner cases
private
static
final
char
[]
OFFENDING_CHARS
=
{
'@'
,
'/'
,
' '
};
// This can grow as we discover corner cases
static
{
...
...
@@ -182,16 +182,13 @@ public abstract class SearchProcessor {
}
protected
void
constructTypeTestQuery
(
StringBuilder
solrQuery
,
Set
<
String
>
typeAndAllSubTypes
)
{
String
typeAndSubtypesString
=
StringUtils
.
join
(
typeAndAllSubTypes
,
SPACE_STRING
);
if
(
CollectionUtils
.
isNotEmpty
(
typeAndAllSubTypes
))
{
if
(
solrQuery
.
length
()
>
0
)
{
solrQuery
.
append
(
AND_STR
);
}
solrQuery
.
append
(
"v.\""
).
append
(
Constants
.
TYPE_NAME_PROPERTY_KEY
).
append
(
"\": ("
)
.
append
(
typeAndSubtypesString
)
.
append
(
")"
);
solrQuery
.
append
(
"v.\""
).
append
(
Constants
.
TYPE_NAME_PROPERTY_KEY
).
append
(
"\":"
);
appendIndexQueryValue
(
typeAndAllSubTypes
,
solrQuery
);
}
}
...
...
@@ -392,6 +389,16 @@ public abstract class SearchProcessor {
return
ret
;
}
protected
String
appendIndexQueryValue
(
Set
<
String
>
values
,
StringBuilder
sb
)
{
sb
.
append
(
BRACE_OPEN_STR
);
for
(
String
value
:
values
)
{
sb
.
append
(
escapeIndexQueryValue
(
value
)).
append
(
SPACE_STRING
);
}
sb
.
append
(
BRACE_CLOSE_STR
);
return
sb
.
toString
();
}
private
static
int
getApplicationProperty
(
String
propertyName
,
int
defaultValue
)
{
try
{
return
ApplicationProperties
.
get
().
getInt
(
propertyName
,
defaultValue
);
...
...
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