A user who works with Norwegian legal material rarely knows a document identifier up front. The starting point is a phrase, a topic, or a date range: "everything about arbeidstid in acts from the last two years". Today the module can list which legal sources exist, but there is no way to find documents inside them, so any real workflow still ends in a browser.
Request
Desired capability
A Search-LovdataDocument command that runs a full-text search across the legal sources the account can reach and returns the hits as objects that can be filtered, sorted, and piped into later commands. It should be able to narrow by legal source, by subject terms, and by date range, and it should return every hit rather than only the first page, because a script that silently sees one page of results produces wrong answers without saying so.
Acceptance criteria
- A phrase search returns matching documents as objects carrying at least the document identifier, title, and legal source
- Results can be narrowed to one or more legal sources, by subject terms, and by a date range
- All matching results are returned by default; limiting the result set is opt-in and explicit
- The number of available hits is discoverable, so a caller can tell whether a query is too broad
- No silent truncation: if anything limits the result set, the caller can see it
- The command works through the stored context like every other command, and its tests pass without an API key
References
GET /v1/search accepts emne1, emne2, emne3, teksthenvisning, base, rows, offset, sortField, sortOrder, fromDate, and toDate
Technical decisions
Code placement: New group src/functions/public/Search/, with the group overview in Search.md. A LovdataSearchResult class under src/classes/public/ models a hit.
Command naming: Search-LovdataDocument. Search is an approved verb and describes the intent; the noun names the resource being searched, not the endpoint.
Paging: The endpoint pages with rows and offset, which is the first paged endpoint in the module. The paging loop belongs in the transport layer next to Invoke-LovdataAPI rather than inside the public command, so the next paged endpoint reuses it. Default behaviour is to follow every page; a -First style parameter caps the result set explicitly.
Parameter design: Follow the object-first rule and give the search its own parameters rather than exposing the raw query names: -Query, -Subject (mapped onto emne1..emne3), -LegalSource, -From, -To, -SortBy, -SortOrder. The Norwegian API parameter names stay internal.
Test approach: Unit tests mocking Invoke-LovdataAPI, covering single-page, multi-page, an explicit result cap, and parameter-to-query mapping.
Depends on: the load-bearing core in #2. The pull request targets build-lovdata-module.
Implementation plan
Core changes
Tests
Documentation
A user who works with Norwegian legal material rarely knows a document identifier up front. The starting point is a phrase, a topic, or a date range: "everything about
arbeidstidin acts from the last two years". Today the module can list which legal sources exist, but there is no way to find documents inside them, so any real workflow still ends in a browser.Request
Desired capability
A
Search-LovdataDocumentcommand that runs a full-text search across the legal sources the account can reach and returns the hits as objects that can be filtered, sorted, and piped into later commands. It should be able to narrow by legal source, by subject terms, and by date range, and it should return every hit rather than only the first page, because a script that silently sees one page of results produces wrong answers without saying so.Acceptance criteria
References
GET /v1/searchacceptsemne1,emne2,emne3,teksthenvisning,base,rows,offset,sortField,sortOrder,fromDate, andtoDateTechnical decisions
Code placement: New group
src/functions/public/Search/, with the group overview inSearch.md. ALovdataSearchResultclass undersrc/classes/public/models a hit.Command naming:
Search-LovdataDocument.Searchis an approved verb and describes the intent; the noun names the resource being searched, not the endpoint.Paging: The endpoint pages with
rowsandoffset, which is the first paged endpoint in the module. The paging loop belongs in the transport layer next toInvoke-LovdataAPIrather than inside the public command, so the next paged endpoint reuses it. Default behaviour is to follow every page; a-Firststyle parameter caps the result set explicitly.Parameter design: Follow the object-first rule and give the search its own parameters rather than exposing the raw query names:
-Query,-Subject(mapped ontoemne1..emne3),-LegalSource,-From,-To,-SortBy,-SortOrder. The Norwegian API parameter names stay internal.Test approach: Unit tests mocking
Invoke-LovdataAPI, covering single-page, multi-page, an explicit result cap, and parameter-to-query mapping.Depends on: the load-bearing core in #2. The pull request targets
build-lovdata-module.Implementation plan
Core changes
LovdataSearchResultclass undersrc/classes/public/src/functions/private/API/Search-LovdataDocumentundersrc/functions/public/Search/Search.mdgroup overview pageTests
Documentation
examples/