Skip to content

Commit b9fdc24

Browse files
author
stlc-bot
committed
feat(news): add natural-language search to POST /news/search (#1975)
Stainless-Generated-From: 09a81533f928b3af5f40bfc94828bfeb806a9bcb
1 parent d0b4bf3 commit b9fdc24

2 files changed

Lines changed: 4 additions & 18 deletions

File tree

‎pkg/cmd/news.go‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import (
1616

1717
var newsSearch = requestflag.WithInnerFlags(cli.Command{
1818
Name: "search",
19-
Usage: "Find company news by name, domain, ticker, or ISIN. Filter articles and continue\nthrough results with a cursor.",
19+
Usage: "Find news about a company by name, domain, ticker, or ISIN, or search all news\nwith a natural-language query. Filter articles and continue through results with\na cursor.",
2020
Suggest: true,
2121
Flags: []cli.Flag{
2222
&requestflag.Flag[map[string]any]{
2323
Name: "search-by",
24-
Usage: "What to search for.",
24+
Usage: "What to search for: a specific company, or a natural-language query across all news.",
2525
Required: true,
2626
BodyPath: "searchBy",
2727
},
@@ -43,8 +43,7 @@ var newsSearch = requestflag.WithInnerFlags(cli.Command{
4343
},
4444
&requestflag.Flag[map[string]any]{
4545
Name: "sort-by",
46-
Usage: "Result ordering. Defaults to newest.",
47-
Default: map[string]any{"type": "newest"},
46+
Usage: "Result ordering. Defaults to newest for entity searches. Natural-language searches are always ordered by relevance.",
4847
BodyPath: "sortBy",
4948
},
5049
&requestflag.Flag[[]string]{
@@ -56,18 +55,6 @@ var newsSearch = requestflag.WithInnerFlags(cli.Command{
5655
Action: handleNewsSearch,
5756
HideHelpCommand: true,
5857
}, map[string][]requestflag.HasOuterFlag{
59-
"search-by": {
60-
&requestflag.InnerFlag[map[string]any]{
61-
Name: "search-by.entity",
62-
Usage: "The company to search news for, identified by name, domain, ticker, or ISIN.",
63-
InnerField: "entity",
64-
},
65-
&requestflag.InnerFlag[string]{
66-
Name: "search-by.type",
67-
Usage: "How to search. Only entity search is supported.",
68-
InnerField: "type",
69-
},
70-
},
7158
"filter-by": {
7259
&requestflag.InnerFlag[[]string]{
7360
Name: "filter-by.article-language",

‎pkg/cmd/news_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ func TestNewsSearch(t *testing.T) {
3535
t,
3636
"--api-key", "string",
3737
"news", "search",
38-
"--search-by.entity", "{domain: stripe.com, type: domain}",
39-
"--search-by.type", "entity",
38+
"--search-by", "{entity: {domain: stripe.com, type: domain}, type: entity}",
4039
"--cursor", "cursor",
4140
"--filter-by.article-language", "[am]",
4241
"--filter-by.article-type", "[editorial]",

0 commit comments

Comments
 (0)