-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content Search and Filter Guide #743
Comments
@dbouwman I have a few questions and comments
|
@thomas-hervey - Thanks for the great comments - appreciate the close reading :)
|
Draft version - looking for feedback
Hub Search Developers Guide
Searching for Content vs Searching for Hub Entities
In Hub we deal with two categories of things - Hub Entities (Site/Page/Project/Initiative etc) and Content (Maps/Apps/Data/Documents).
Although the Hub Entities can be thought of as “Content”, generally when working with specific entities, we will use the
.search
methods on the Entity Manager classes, or thesearch[EntityType]
functions in the entity modules. The key thing is that these methods will return the expected Hub Entity (i.e. for projects you get backIHubProject
objects), where as the more generic content search will return anIHubContent
, even for Hub Entity types.Searching for Content
To search for content, we want to use:
NOTE: the
_
is temporary. The currently exportedsearchContent
function operates very differently. We will use an incremental process to convert client code over to using the new functions, and then deprecate the old implementation at a breaking change in Hub.jsThe response contains an array of results, and a
next()
function which fetches the next page.Content Search Filters
The
Filter
is a tagged union type, and it's properties depend on the tag passed in when it's declared.While
Filter<"content">
has different properties thanFilter<"user">
, using a tagged union type allows us to write generic functions to handle merging and serialization.When working with
Filter<"content">
the filter interface is defined as followsThe listed properties are those supported by the Portal API. It also supports additional properties, but those will ignored by the Portal API search, and may be respected by the Hub API.
Building Filters
The core idea is that complex queries can be built up from many simple Filters. For a simple example, to locate items owned by
jsmith
of typeWeb Map
, we could create two filters and merge them as followsWhile that example could have been written as a single filter without much issue, this approach of merging many filters into a single filter is core to how the
Filter
system works. It's also enables the UI layer to be composed of many small components, which define simple Filters, which are merged to create a single complex Filter, which is serialized into a query that is executed against the Portal or Hub API.Complex Filters
Sometimes we need to express more complex logic. As shown in the
IContentFilterDefinition
interface above, properties on aFilter
can be a string, but can also be an array of strings, or the more complexIMatchOptions
.Let's look at an array of strings first.
We can read this as
where type = "Web Map" or type = "Dashboard"
. If we need to be even more specific, we need to use theIMatchOptions
Using IMatchOptions
When you need very specific control over the boolean logic, we drop to the
IMatchOptions
interface.For example, to find items with the tags
water
andcolorado
, optionally with tagslake
andstream
, but without the tagsepa
,nepa
and matching exactly the type"Feature Service"
we could use this filter:A Note About Exact Matching
As the Portal Search API documentation notes (Query vs Filter section), by default the api does a "fuzzy search" - this means that searching for
type:"Web Map"
will also return things withtype: "Web Mapping Application"
. To do an exact match, the query is structured differently (for the Portal API, this criteria is serialized into thefilter
property vs theq
).Filter
design accomodates this via theIMatchOptions.exact
property. It should be noted that the portal API accepts a subset of properties on thefilter
parameter. From the docs:Exact Match Fields by Filter Type
title
tags
typeKeywords
type
name
owner
username
firstname
lastname
fullname
email
title
typeKeywords
owner
SubFilters
While rare, some scenarios require an "OR" between two complex queries that do not intersect. For example, to find all "StoryMaps" the query logic is as follows:
As a Filter this would be done as follows:
Well-Known Filters
The Filter system has some built in short-cuts for some commonly used filters.
$apps
$storymap
$dashboard
$site
$initiative
$document
$experience
Search Options
Once we have constructed the filter, the next thing needed are the search options. The inteface is shown below, and for the most part it's information like authentication, sorting and paging.
Specifying the API
NOTE This is likely to change!
Searches can be run against the Portal API or against the Hub API. This is specified by the
.api
property of theIHubSearchOptions
The
.api
property can take either a well-known name (NamedApis
type) or anIApiDefinition
arcgis
arcgisQA
arcgisDEV
hub
hubQA
hubDEV
To work with an ArcGIS Enterprise instance a full
IApiDefinition
must be provided:The text was updated successfully, but these errors were encountered: