Filters allow you reduce the number of search results by defining matching criteria on the items.
For example, you can find all items where the last_modified
field is between a specific date range.
You can filter full text search results by adding a filters
object to the search request object.
POST /api/data/search
{
"query": "{query}",
"limit": {limit},
"page": {page},
"filters": {
"terms": [{terms}],
"multi_terms": [{multi_terms}],
"ranges": [{ranges}],
"exists": [{exists}],
"not_exists": [{exists}]
}
}
filters
object must have at least one property, which is one of the types of filters that may be appliedquery
value, but they are more expensiveThere are four types of filters:
terms
- Find objects where fields match specified termsmulti_terms
- Find objects where fields match one of many specified termsranges
- Find objects where fields fit within a specified rangeexists
- Find objects that have a value for the specified fieldsnot_exists
- Find objects that don’t have a value for the specified fieldsterms
filtersThe filters.terms
array allows you to specify a list of terms to match.
For example, to find all objects that have a specified md5
you would make the following request:
POST /api/data/search
{
"query": "{query}",
"filters": {
"terms": [
{"field":"md5", "value":"2ece57080d9545702d51cf1394b94142"}
]
}
}
field
- (string) The field to apply the filter tovalue
- (string) The value to matchmulti_terms
filtersThe filters.multi_terms
array allows you to specify many values which objects must match.
For example, to find all objects that have an extension of png
or jpg
, you would make the following request:
POST /api/data/search
{
"query": "{query}",
"filters": {
"multi_terms": [
{"field":"ext", "value":"png,jpg"}
]
}
}
field
- (string) The field to apply the filter tovalue
- (string) Comma separated list of values to matchranges
filtersThe filters.ranges
array allows you to specify a range of values for a given field.
For example, to find all items that were last modified between two dates you would make the following request:
POST /api/data/search
{
"query": "{query}",
"filters": {
"ranges": [
{ "field": "last_modified", "from": "2016-05-24", "to": "now"}
]
}
}
field
- (string) The field to apply the filter tofrom
- (string) The lower bound of the range to matchto
- (string) The upper bound of the range to match"now"
is a special value that indicates the current date time.
exists
filtersThe filters.exists
array allows you to specify fields that must appear in the matching items.
Items that do not have a value for the specified field will not appear in the results.
For example, to match all items that have exiv2
metadata, you would make the following request:
POST /api/data/search
{
"query": "{query}",
"filters": {
"exists": ["exiv2"]
}
}
exists
- (array of string) List of fields that must exist for an item to appear in the search resultsThis documentation is generated from the latest version of GrayMeta Platform. For documentation relevant to your own deployed version, please use the documentation inside the application.
© 2021 GrayMeta, Inc.