Free Text Search
The parameter query allows for free-text searching across data-points on the shipment records. A query consists of three parts:
- Text content (what to search for)
- Target Fields (where to look)
- Searching Logic (how to search)
Text Content
This is the actual text content that is used to search against the data in the shipment records. This is specified in the query.text parameter.
Target Fields
These are the unique data-points (or fields) on each shipment record that will be evaluated against the provided text content. There are two ways to provide the target fields for a query, by specifying either:
- A pre-defined group of fields by using the
query.groupparameter. - A custom set of fields by using the
query.custom_groupparameter.
Depending on the use case at hand some fields may be substantially more desirable than other.
For example, if only the contents of the shipment are in question, using the group goods_described will remove results where the shipper's name may contain the search term.
Searching Logic
By default, any individual word in the provided search content may match the shipment record to qualify as a hit. Also, only the root of the provided word must match.
For example, a search for purple shoes may return shipments for both purple paint and track shoe.
The search logic may be tailored further with three additional settings:
- ALL terms must match if
query.operatoris set toAND - Provided terms must match exactly (
shoeswill not matchshoe) ifquery.matchis set toexact - Multiple Queries may be provided using the
queriesparameter. Note: Every query must match the record - Joins, Exclusions, Groups, Phrases and more are available using inline operators as further described in the schema below.
Query Examples
Let's take a look at a few different ways that query can be used to search for footwear within shipments, ranging broad searches to more precise.
Search Broadly Across All Record Fields
Find Shipments that contain any footwear terms in either the shipper's name, the consignee's name, or the shipment's item descriptions.
{
"data_source": "global",
"query": {
"text": "shoes footwear boots heels sneakers"
}
}
Search only Shipment Descriptions
Find Shipments that contain any footwear terms only in the shipment's descriptions.
{
"data_source": "global",
"query": {
"text": "shoes footwear boots heels sneakers".
"group": "goods_described"
}
}
Every search term must match
Find shipments that contain all three terms of sneakers, white, track, regardless of where those terms are present on the shipment record.
{
"data_source": "global",
"query": {
"text": "sneakers white track",
"operator": "AND
}
}
Matching an entire phrase
Find shipments that contain all three terms of high heel shoes sequentially
{
"data_source": "global",
"query": {
"text": "\"high heel shoes\"",
}
}
Using Inline Operators and Exact Term Matching
Find shipments that contain exactly shoes, along with either high heel or heel.
{
"data_source": "global",
"query": {
"text": "(\"high heel\" | heel) +shoes",
"match": "exact"
}}
Since match: "exact" is specified, shoe, heels, heeled, or other variations of the provided term will not qualify as a match.
Using Multiple Queries and Custom Groups
Find shipments that contain shoes in the description, and footwear in either the shipper's name or industry
{
"data_source": "global",
"queries": [
{
"text": "shoes",
"group": "goods_described"
}, {
"text": "footwear",
"custom_group": ["shipper_name", "shipper_industry"]
}
]
}