Search
exists_query(field)
¶
A convenience function which returns an exists query for the given field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
the field path |
required |
Returns:
| Type | Description |
|---|---|
Query
|
an exists query on the field using the full parsed path |
Source code in splitgill/search.py
110 111 112 113 114 115 116 117 | |
has_geo()
¶
Create an exists query which filters for records which have geo data. Currently, this uses ALL_POINTS, but it could just as easily use ALL_SHAPES, it doesn't matter.
Returns:
| Type | Description |
|---|---|
Query
|
an exists Query object |
Source code in splitgill/search.py
100 101 102 103 104 105 106 107 | |
id_query(record_id)
¶
Returns a term query on the _id field in the record's data with the record_id value passed. This uses the data's _id not the documents ID root field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record_id
|
str
|
the record's ID |
required |
Returns:
| Type | Description |
|---|---|
Query
|
a term query |
Source code in splitgill/search.py
35 36 37 38 39 40 41 42 43 | |
index_specific_version_filter(indexes_and_versions)
¶
Creates the elasticsearch-dsl Bool object necessary to query the given indexes at the given specific versions. If there are multiple indexes that require the same version then a terms.
The query will be created covering the group rather than several term queries for each index - this is probably no different in terms of performance, but it does keep the size of the query down when large numbers of indexes are queried. If all indexes require the same version then a single term query is returned (using the create_version_query above) which has no index filtering in it at all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indexes_and_versions
|
Dict[str, int]
|
a dict of index names -> versions |
required |
Returns:
| Type | Description |
|---|---|
Query
|
an elasticsearch-dsl Query object |
Source code in splitgill/search.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
infer_parsed_type(value)
¶
Given a value, infer the ParsedType based on the type of the value.
If no ParsedType can be matched, a ValueError is raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Union[int, float, str, bool, date, datetime]
|
the value |
required |
Returns:
| Type | Description |
|---|---|
ParsedType
|
a ParsedType |
Source code in splitgill/search.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
match_query(query, field=None, **match_kwargs)
¶
Create and return a match query using the given query and the optional field name. If the field name is not specified, all text data is searched instead using the ALL_TEXT field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
the query to match |
required |
field
|
Optional[str]
|
the field to query, or None if all fields should be queried |
None
|
match_kwargs
|
additional options for the match query |
{}
|
Returns:
| Type | Description |
|---|---|
Query
|
a Query object |
Source code in splitgill/search.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
range_query(field, gte=None, lt=None, gt=None, lte=None, parsed_type=None, **range_kwargs)
¶
Create and return a range query using the given parameters to specify the extent. At least one of the gte/lt/gt/lte parameters must be specified otherwise a ValueError is raised. If the parsed_type parameter is not specified, it will be inferred from the first non-None gte/lt/gt/lte parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
the field to query |
required |
gte
|
Union[int, float, str, date, datetime]
|
the greater than or equal to value |
None
|
lt
|
Union[int, float, str, date, datetime]
|
the less than value |
None
|
gt
|
Union[int, float, str, date, datetime]
|
the greater than value |
None
|
lte
|
Union[int, float, str, date, datetime]
|
the less than or equal to value |
None
|
parsed_type
|
Optional[ParsedType]
|
the parsed type of the field to use, or None to infer from value |
None
|
range_kwargs
|
additional options for the range query |
{}
|
Returns:
| Type | Description |
|---|---|
Query
|
a Query object |
Source code in splitgill/search.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
rebuild_data(parsed_data)
¶
Rebuild the original data from the parsed version of the data created by the parse function above.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parsed_data
|
dict
|
the parsed dict |
required |
Returns:
| Type | Description |
|---|---|
dict
|
the rebuilt data dict |
Source code in splitgill/search.py
236 237 238 239 240 241 242 243 244 245 246 | |
rebuild_dict_or_list(value)
¶
Rebuild a dict or a list inside the parsed dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Union[dict, list]
|
a dict which can either be for structure or a value, or a list of either value or structure dicts |
required |
Returns:
| Type | Description |
|---|---|
Union[int, str, bool, float, dict, list, None]
|
a dict, list, or value |
Source code in splitgill/search.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
term_query(field, value, parsed_type=None)
¶
Create and return a term query which will find documents that have an exact value match in the given field. If the parsed_type parameter is not specified, it will be inferred based on the value type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
the field match |
required |
value
|
Union[int, float, str, bool, date, datetime]
|
the value to match |
required |
parsed_type
|
Optional[ParsedType]
|
the parsed type of the field to use, or None to infer from value |
None
|
Returns:
| Type | Description |
|---|---|
Query
|
a Q object |
Source code in splitgill/search.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
version_query(version)
¶
Creates the elasticsearch-dsl term necessary to find the correct data from some searched records given a version. You probably want to use the result of this function in a filter, for example, to find all the records at a given version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
int
|
the requested version |
required |
Returns:
| Type | Description |
|---|---|
Query
|
an elasticsearch-dsl Query object |
Source code in splitgill/search.py
46 47 48 49 50 51 52 53 54 55 | |