Open dbouwman opened 2 years ago
@dbouwman I have a few questions and comments
"The key thing is that these methods will return the expected Hub Entity (i.e. for projects you get back IHubProject objects), where as the more generic content search will return an IHubContent, even for Hub Entity types."
IHubSite
? "To do an exact match, the query is structured differently, and the Filter design accomodates this via the IMatchOptions.exact property."
How exactly does IMatchOptions.exact
get around Portal's fuzzy search? Does it still call the search endpoint?
Why exactly are listed "well-known filters" well-known? Seems like they include Hub family types, items, and shortcuts for item types (ex. $experience
). I ask because I wonder if we still need to clarify the content classification relationships between families, items, and labels discussed in this comment back in 2020
Which search options are required vs optional? Are there defaults for each?
"To work with an ArcGIS Enterprise instance a full IApiDefinition must be provided"
I think it would be useful to include a full example for the IApiDefinition interface definition
Looks like a few typos
NamedApis
table. ex. hubQA --> ArcGIS Hub @thomas-hervey - Thanks for the great comments - appreciate the close reading :)
exact
into the filter
property on the search request, vs in the q
property (which is fuzzy). Although any property can specify exact
there is a subset of fields which the api actually supports, and this was something we were not able to enforce via the type system when we built the initial version. Reviewing now, I think that may be possible, but honestly does not matter much b/c the filter json is created at runtime when there is no type checking. I've added notes about the supported fields.Documents
facet globally by simply updating the definition of $document
vs changing json in 35 places.
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: