Search-Basic.md 5.96 KB
Newer Older
1 2 3 4 5 6
---
name: Basic Search
route: /Search-Basic
menu: Documentation
submenu: Search 
---
7

8 9 10 11 12 13 14 15
import  themen  from 'theme/styles/styled-colors';
import  * as theme  from 'react-syntax-highlighter/dist/esm/styles/hljs';
import SyntaxHighlighter from 'react-syntax-highlighter';
import Img from 'theme/components/shared/Img'

# Basic Search

The basic search allows you to query using typename of an entity, associated classification/tag and has support for filtering on the entity attribute(s) as well as the classification/tag attributes.
16 17 18

The entire query structure can be represented using the following JSON structure (called !SearchParameters)

19 20
<SyntaxHighlighter wrapLines={true} language="json" style={theme.dark}>
{`{
21
  "typeName":               "hive_column",
22
  "excludeDeletedEntities": true,
23 24 25 26 27 28 29
  "classification":         "PII",
  "query":                  "",
  "offset":                 0,
  "limit":                  25,
  "entityFilters":          {  },
  "tagFilters":             { },
  "attributes":             [ "table", "qualifiedName"]
30 31
}`}
</SyntaxHighlighter>
32

33
**Field description**
34

35 36 37 38 39 40 41 42 43 44 45
 <SyntaxHighlighter wrapLines={true} language="json" style={theme.dark}>
   {`typeName:               the type of entity to look for
excludeDeletedEntities: should the search exclude deleted entities? (default: true)
classification:         only include entities with given classification
query:                  any free text occurrence that the entity should have (generic/wildcard queries might be slow)
offset:                 starting offset of the result set (useful for pagination)
limit:                  max number of results to fetch
entityFilters:          entity attribute filter(s)
tagFilters:             classification attribute filter(s)
attributes:             attributes to include in the search result`}
</SyntaxHighlighter>
46

47
<Img src={`/images/twiki/search-basic-hive_column-PII.png`} height="400" width="600"/>
48

49
   Attribute based filtering can be done on multiple attributes with AND/OR conditions.
50

51
**Examples of filtering (for hive_table attributes)**
52
   * Single attribute
53 54 55
   
<SyntaxHighlighter wrapLines={true} language="json" style={theme.dark}>
{`   {
56
     "typeName":               "hive_table",
57
     "excludeDeletedEntities": true,
58 59
     "offset":                 0,
     "limit":                  25,
60
     "entityFilters": {
61 62 63
        "attributeName":  "name",
        "operator":       "contains",
        "attributeValue": "customers"
64
     },
65
     "attributes": [ "db", "qualifiedName" ]
66 67
   }`}
</SyntaxHighlighter>
68

69
<Img src={`/images/twiki/search-basic-hive_table-customers.png`} height="400" width="600"/>
70

71
   * Multi-attribute with OR
72 73 74

<SyntaxHighlighter wrapLines={true} language="json" style={theme.dark}>
{`   {
75
     "typeName":               "hive_table",
76
     "excludeDeletedEntities": true,
77 78
     "offset":                 0,
     "limit":                  25,
79 80 81 82
     "entityFilters": {
        "condition": "OR",
        "criterion": [
           {
83 84 85
              "attributeName":  "name",
              "operator":       "contains",
              "attributeValue": "customers"
86 87
           },
           {
88 89 90
              "attributeName":  "name",
              "operator":       "contains",
              "attributeValue": "provider"
91 92 93
           }
        ]
     },
94
     "attributes": [ "db", "qualifiedName" ]
95 96
   }`}
</SyntaxHighlighter>
97

98
<Img src={`/images/twiki/search-basic-hive_table-customers-or-provider.png`} height="400" width="600"/>
99

100
   * Multi-attribute with AND
101 102 103

<SyntaxHighlighter wrapLines={true} language="json" style={theme.dark}>
{`   {
104
     "typeName":               "hive_table",
105
     "excludeDeletedEntities": true,
106 107
     "offset":                 0,
     "limit":                  25,
108 109 110 111
     "entityFilters": {
        "condition": "AND",
        "criterion": [
           {
112 113 114
              "attributeName":  "name",
              "operator":       "contains",
              "attributeValue": "customers"
115 116
           },
           {
117 118 119
              "attributeName":  "owner",
              "operator":       "eq",
              "attributeValue": "hive"
120 121 122
           }
        ]
     },
123
     "attributes": [ "db", "qualifiedName" ]
124 125
  }`}
</SyntaxHighlighter>
126

127
<Img src={`/images/twiki/search-basic-hive_table-customers-owner_is_hive.png`} height="400" width="600"/>
128

129
**Supported operators for filtering**
130 131 132 133 134 135 136 137 138 139 140 141

   * LT (symbols: <, lt) works with Numeric, Date attributes
   * GT (symbols: >, gt) works with Numeric, Date attributes
   * LTE (symbols: <=, lte) works with Numeric, Date attributes
   * GTE (symbols: >=, gte) works with Numeric, Date attributes
   * EQ (symbols: eq, =) works with Numeric, Date, String attributes
   * NEQ (symbols: neq, !=) works with Numeric, Date, String attributes
   * LIKE (symbols: like, LIKE) works with String attributes
   * STARTS_WITH (symbols: startsWith, STARTSWITH) works with String attributes
   * ENDS_WITH (symbols: endsWith, ENDSWITH) works with String attributes
   * CONTAINS (symbols: contains, CONTAINS) works with String attributes

142
**CURL Samples**
143

144 145
<SyntaxHighlighter wrapLines={true} language="shell" style={theme.dark}>
{`curl -sivk -g
146 147 148
    -u <user>:<password>
    -X POST
    -d '{
149
            "typeName":               "hive_table",
150
            "excludeDeletedEntities": true,
151 152 153 154
            "classification":         "",
            "query":                  "",
            "offset":                 0,
            "limit":                  50,
155 156 157 158
            "entityFilters": {
               "condition": "AND",
               "criterion": [
                  {
159 160 161
                     "attributeName":  "name",
                     "operator":       "contains",
                     "attributeValue": "customers"
162 163
                  },
                  {
164 165 166
                     "attributeName":  "owner",
                     "operator":       "eq",
                     "attributeValue": "hive"
167 168 169
                  }
               ]
            },
170
            "attributes": [ "db", "qualifiedName" ]
171
          }'
172 173
    <protocol>://<atlas_host>:<atlas_port>/api/atlas/v2/search/basic`}
</SyntaxHighlighter>