UpStart Commerce Search
Query Algebra
14min
there are multiple query rules you can use to build up any desired condition based on this algebra of rules, the search will decide if the query is matching and thus triggering some action or not following are a few examples of the query rules algebra to learn about various types and their usage always { "type" "always" } the query always matches never { "type" "never" } the query never matches match in specific field { "field" "manufacturername", "type" "queryhasfield" } query matches if it contains field query on manufacturername e g “tshirt && manufacturername\ hugoboss” match with specific value { "field" "siteid", "value" "1234", "type" "queryhasfield" } query matches if it contains field siteid with a precise value of “1234” e g “tshirt && siteid 1234” match if query present in any field { "value" "iphone", "field" { "type" "anyfield" }, "type" "queryhasvalue" } query matches if there is the term “iphone” in any place e g “name\ iphone” match without specified field name { "value" "iphone", "field" { "type" "emptyfield" }, "type" "queryhasvalue" } query matches if there is term “iphone”, but only when specified without the field name e g “iphone || name mac” match with either fields { "value" "iphone", "field" { "fields" \[ "manufacturername", "name" ], "type" "fieldnamesspecified" }, "type" "queryhasvalue" } query matches if there is the term “iphone” in either manufacturername or name fields e g “mac || name iphone” match for any field { "value" "computer", "field" { "type" "anyfield" }, "type" "querycontainsvalue" } query matches if part of the query term, in any field, is a “computer” e g “bestcomputer” match without specified fields { "value" "computer", "field" { "type" "emptyfield" }, "type" "querycontainsvalue" } query matches if part of a query term is a “computer”, but only for terms without fields specified match with specified field { "value" "computer", "field" { "fields" \[ "manufacturername", "name" ], "type" "fieldnamesspecified" }, "type" "querycontainsvalue" } query matches if part of a query term is a “computer”, but only for fields manufacturername and name match if present in any field { "term" { "value" "tshirts", "field" { "type" "anyfield" }, "type" "queryhasvalue" }, "type" "not" } query matches if it doesn’t contain the value “tshirt” in any of its fields e g “tshirts” e g “computer“ match with any field with multiple queries { "terms" \[ { "value" "iphone", "field" { "type" "anyfield" }, "type" "queryhasvalue" }, { "value" "apple", "field" { "type" "anyfield" }, "type" "querycontainsvalue" } ], "type" "or" } query matches if it has the term “iphone” in any field or if part of the query contains “apple” { "terms" \[ { "value" "iphone", "field" { "type" "anyfield" }, "type" "queryhasvalue" }, { "value" "apple", "field" { "fields" \[ "manufacturername" ], "type" "fieldnamesspecified" }, "type" "querycontainsvalue" } ], "type" "and" } query matches if it has the term “iphone” in any field and if the manufacturername query contains “apple”