Skip to content

Commit 68a81c8

Browse files
claudeLutherwaves
authored andcommitted
feat: add SearchQuery schema with Lucene search examples to OpenAPI definitions
Added SearchQuery schema to types/types.go with 34 comprehensive examples covering all Lucene search capabilities: Schema Structure: - Type: string - Description: Full Lucene query syntax reference - Default example: "name:john AND status:active" - 34 example queries covering: * Basic field searches and wildcards * Boolean operators (AND, OR, NOT, +, -) * Range queries (inclusive, exclusive, open-ended, dates) * Quoted phrases and escaped characters * Complex nested queries * Implicit search across string fields * JSONB/nested field access (field.subfield:value) * Null value queries (field:null) * Fuzzy search (term~, term~2) Usage in Swagger/OpenAPI annotations: schema: $ref: "#/components/schemas/SearchQuery" Or in Go swaggo annotations: // @Param query query string false "Search query" SchemaExample(SearchQuery) This provides a reusable schema definition similar to PatchBody, making it easy for API consumers to understand and use Lucene query syntax for filtering and searching resources. Related to PR tink3rlabs#124 which added Lucene search support.
1 parent 2d239e3 commit 68a81c8

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

types/types.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,49 @@ const definitions = `
136136
"description": "A string containing a JSON Pointer value."
137137
}
138138
}
139+
},
140+
"SearchQuery": {
141+
"type": "string",
142+
"description": "Lucene-style search query supporting field searches, wildcards, boolean operators, ranges, and more. Syntax: field:value, wildcards (*,?), operators (AND, OR, NOT, +, -), ranges ([min TO max]), quoted phrases, JSONB access (field.subfield:value), null checks (field:null), and fuzzy search (term~).",
143+
"example": "name:john AND status:active",
144+
"examples": [
145+
"name:john",
146+
"name:john*",
147+
"email:*@example.com",
148+
"description:*important*",
149+
"name:john* OR email:*@example.com",
150+
"name:john AND status:active",
151+
"status:active OR status:pending",
152+
"name:john NOT status:inactive",
153+
"+name:john +status:active",
154+
"name:john -status:deleted",
155+
"age:[25 TO 65]",
156+
"age:{25 TO 65}",
157+
"age:[25 TO *]",
158+
"age:[* TO 65]",
159+
"created_at:[2024-01-01 TO 2024-12-31]",
160+
"description:\"hello world\"",
161+
"title:\"test-app (v1.0)\"",
162+
"name:C\\+\\+ OR path:\\/usr\\/bin",
163+
"(name:john* OR email:*@example.com) AND status:active AND age:[25 TO 65]",
164+
"((name:john OR name:jane) AND status:active) OR (status:pending AND age:[18 TO *])",
165+
"searchterm",
166+
"john*",
167+
"labels.category:production",
168+
"metadata.tags:prod*",
169+
"name:john AND labels.env:prod AND metadata.team:engineering",
170+
"parent_id:null",
171+
"NOT deleted_at:null",
172+
"name:john AND deleted_at:null",
173+
"name:roam~",
174+
"name:roam~2",
175+
"labels.tag:prod~",
176+
"+name:john* -status:deleted age:[25 TO 65] AND (role:admin OR role:moderator)",
177+
"name:john OR email:john@example.com OR phone:*555*",
178+
"(name:*admin* OR role:administrator) AND status:active AND NOT deleted_at:null AND created_at:[2024-01-01 TO *]"
179+
]
139180
}
140-
}
181+
}
141182
}
142183
}
143184
`

0 commit comments

Comments
 (0)