UpStart Commerce Search

Routes

6min
routes serve as the middle layer that groups indexes, query pipelines, and levels of access through them, users can define which type of search access is granted to users routes also provide the ability to search multiple indexes at the same time the following diagram represents the role and interaction of routes in search access three different types of accesses can be provided public in this type, access is granted to everybody, even those who do not have a token i e end customers with an anonymous token permission only users with proper permission can access these types of routes 'permission' is dynamically created while a route is created or updated customer specific in this type of access, customers are granted access to view their data such as order history, cart, and other similar information customer id has to be provided via http header 'x upstart customerid' when a route is created, it is possible to execute operations such as search and suggest dynamically based on configured access crud operations are also available for the management of routes creating a route for the sake of example, while creating a route, we will consider the existing query pipeline and filter query rule that was created in the query pipeline docid\ syjm cutkdxgvmtsey2x guide to create a route, the following endpoint is used post https //api upstartcommerce com/v1/search/routes { "tenant" "sitename", "appid" "default", "id" "hpcharacters", "displayname" "harry potter characters", "access" "public", "indexes" \[ { "id" "hp characters", "querypipeline" "hprules" } ] } it is necessary to define the id of the index but optional to define the query pipeline we want to associate with this route the unique id of the route in the example above is set to "hpcharacters" the access level is also defined as "public" in the beginning search in route continuing the example above, the following is the request to search in the route the following endpoint is used for this purpose post https //api upstartcommerce com/v1/search/routes/hpcharacters/search { "search" { "query" { "bool" { "must" \[ { "query string" { "query" "half blood" } } ] } }, "from" 0, "size" 20, "aggs" {} } } response the following code block represents a snippet of the response generated { "result" { "queryid" "73715673 fc69 45c8 99b8 cbd0a22fd445", "data" { "hits" { "total" { "value" 1, "relation" "eq" }, "hits" \[ { " index" "sp sitename default hp characters 000001", " type" " doc", " id" "jcoi1h4br gifr7ddfmo", " source" { "name" "harry potter", "species" "human", "gender" "male", "house" "gryffindor", "dateofbirth" "31 07 1980", "yearofbirth" 1980, "ancestry" "half blood", "eyecolour" "green", "haircolour" "black", "wand" { "wood" "holly", "core" "phoenix feather", "length" 11 }, "patronus" "stag", "hogwartsstudent" true, "hogwartsstaff" false, "actor" "daniel radcliffe", "alive" true, "image" "http //hp api herokuapp com/images/harry jpg" } } ] } }, "aggregations" {}, "type" "searchresponseanswer" } } notice that the "half blood" document in the ancestry is returned in the search results via routes