Documentation
¶
Overview ¶
Package query provides a query parser and validator for DPMAregister expert search syntax.
DPMAregister uses an expert search syntax with field codes like TI=Elektrofahrzeug, Boolean operators (AND/UND, OR/ODER, NOT/NICHT), comparison operators (=, >=, <=, >, <), wildcards (? any chars, ! one char, # one or no char), quoted values, and parentheses.
Procedure data searches use curly braces: {VST=pub-offenlegungschrift UND VSTT=05.01.2011}
Each DPMA service (Patent, Design, Trademark) supports different field codes. Use ParseQuery to parse and validate queries, optionally scoped to a specific service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetValidFields ¶
GetValidFields returns all valid field codes for a service. If service is ServiceAny, returns fields from all services (deduplicated).
func IsValidField ¶
IsValidField checks if a field code is valid for the given service. If service is ServiceAny, the field is checked against all services.
func IsValidOperator ¶
IsValidOperator checks if a string is a recognized Boolean operator.
Types ¶
type Field ¶
type Field struct {
// Code is the field abbreviation used in queries (e.g. "TI", "INH").
Code string
// Name is the German field name (e.g. "Bezeichnung/Titel").
Name string
// Description is a brief English description.
Description string
// Input is the expected input type (text or date).
Input InputType
// Services lists which services support this field.
Services []Service
}
Field describes a DPMAregister search field.
type Query ¶
type Query struct {
// Raw is the original query string.
Raw string
// Tokens is the parsed token stream.
Tokens []Token
// Valid indicates whether the query passed validation.
Valid bool
// Errors contains any validation errors.
Errors []string
// Service is the service context used for field validation.
Service Service
}
Query represents a parsed DPMAregister expert search query.
func ParseQuery ¶
ParseQuery parses a DPMAregister expert search query string and returns a Query with tokens and validation results.
If service is not ServiceAny, field names are validated against that service's known field codes.
Example queries:
- "TI=Elektrofahrzeug"
- "TI=Elektrofahrzeug AND INH=Siemens"
- "(TI=Motor OR TI=Antrieb) AND IC=H02K?"
- "INH=\"München\" AND AT>=01.01.2024"
- "{VST=pub-offenlegungschrift UND VSTT=05.01.2011}"
- "MARKE=?brain?"
- "exists INH"
func (*Query) TokenCount ¶
TokenCount returns the number of tokens in the parsed query.
type Service ¶
type Service string
Service represents a DPMAregister service type for field validation.
const ( // ServicePatent validates against patent and utility model fields (Schutzrechtsart P, G). ServicePatent Service = "patent" // ServiceDesign validates against design fields (Schutzrechtsart G for Geschmacksmuster). ServiceDesign Service = "design" // ServiceTrademark validates against trademark fields (Marke). ServiceTrademark Service = "trademark" // ServiceAny accepts fields from any service (no service-specific validation). ServiceAny Service = "" )
type TokenType ¶
type TokenType int
TokenType represents the type of a query token.
const ( TokenField TokenType = iota // Field name (before =) TokenOperator // Boolean operator (AND, OR, NOT, UND, ODER, NICHT) TokenValue // Search value TokenEquals // Comparison operator (=, >=, <=, >, <) TokenLParen // ( TokenRParen // ) TokenLBrace // { (procedure data) TokenRBrace // } (procedure data) TokenQuote // " TokenWhitespace // Whitespace (stripped during tokenization) TokenUnknown // Unrecognized )
TokenType constants for DPMAregister query tokens.