-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-file-search.go
More file actions
43 lines (36 loc) · 990 Bytes
/
test-file-search.go
File metadata and controls
43 lines (36 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"context"
"fmt"
"log"
"github.com/hyperifyio/goresearch/internal/search"
)
func main() {
provider := &search.FileProvider{Path: "./fixtures/hello-search.json"}
// Test query that should match
query := "Hello Research — Brief introduction to goresearch specification"
results, err := provider.Search(context.Background(), query, 10)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Query: %s\n", query)
fmt.Printf("Results: %d\n", len(results))
for i, r := range results {
fmt.Printf("%d. %s\n", i+1, r.Title)
fmt.Printf(" URL: %s\n", r.URL)
fmt.Printf(" Snippet: %s\n", r.Snippet)
fmt.Printf("\n")
}
// Also test with a simpler query
fmt.Println("---")
query2 := "hello"
results2, err := provider.Search(context.Background(), query2, 10)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Query: %s\n", query2)
fmt.Printf("Results: %d\n", len(results2))
for i, r := range results2 {
fmt.Printf("%d. %s\n", i+1, r.Title)
}
}