Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you hit quic-go "you're using can't be built on Go 1.21 yet" #1

Open
reactima opened this issue Apr 21, 2024 · 1 comment
Open

Comments

@reactima
Copy link

reactima commented Apr 21, 2024

If you hit quic-go "you're using can't be built on Go 1.21 yet"

cannot use "The version of quic-go you're using can't be built on Go 1.21 yet. For more details, please see https://github.com/quic-go/quic-go/wiki/quic-go-and-Go-versions." (untyped string constant "The version of quic-go you're using can't be built on Go 1.21 yet. F...) as int value in variable declaration

/api/v1/{indexId}/search
https://github.com/quickwit-oss/quickwit-go/blob/main/client.go#L68C9-L68C33

the following code snippet might help to build your own lib

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

type SearchRequest struct {
	Query          string   `json:"query"`
	SearchFields   []string `json:"search_field,omitempty"`
	StartTimestamp int64    `json:"start_timestamp,omitempty"`
	EndTimestamp   int64    `json:"end_timestamp,omitempty"`
	MaxHits        uint64   `json:"max_hits"`
	StartOffset    uint64   `json:"start_offset,omitempty"`
	SortByField    string   `json:"sort_by_field,omitempty"`
}

type Hit struct {
	AnswerID     int    `json:"answerId"`
	Body         string `json:"body"`
	CreationDate string `json:"creationDate"`
	QuestionID   int    `json:"questionId"`
	Type         string `json:"type"`
	User         string `json:"user"`
}

type SearchResponse struct {
	NumHits           uint64      `json:"num_hits"`
	Hits              []Hit       `json:"hits"`
	ElapsedTimeMicros uint64      `json:"elapsed_time_micros"`
	Aggregations      interface{} `json:"aggregations,omitempty"`
}

func main() {
	// Define the search query
	indexID := "stackoverflow"
	query := SearchRequest{
		Query:   "search AND engine",
		MaxHits: 20,
	}
	queryBody, _ := json.Marshal(query)

	// Create an HTTP client and request
	client := &http.Client{}
	req, err := http.NewRequest("POST", "http://localhost:7280/api/v1/"+indexID+"/search", bytes.NewBuffer(queryBody))
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}
	req.Header.Set("Content-Type", "application/json")

	// Execute the request
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error making HTTP call:", err)
		return
	}
	defer resp.Body.Close()

	// Read and parse the response body
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("Error reading response body:", err)
		return
	}

	var result SearchResponse
	if err := json.Unmarshal(body, &result); err != nil {
		fmt.Println("Error parsing JSON response:", err)
		return
	}

	fmt.Printf("Total hits: %d\n", len(result.Hits))
	for _, hit := range result.Hits {
		fmt.Printf("\nType: %s\nAnswerID: %d\nBody: %s\n\n", hit.Type, hit.AnswerID, hit.Body)
	}
}

assuming you followed the quickstart https://quickwit.io/docs/get-started/quickstart

# Index config file for stackoverflow dataset.
#
version: 0.8

index_id: stackoverflow

doc_mapping:
  field_mappings:
    - name: title
      type: text
      tokenizer: default
      record: position
      stored: true
    - name: body
      type: text
      tokenizer: default
      record: position
      stored: true
    - name: creationDate
      type: datetime
      fast: true
      input_formats:
        - rfc3339
      fast_precision: seconds
  timestamp_field: creationDate

search_settings:
  default_search_fields: [title, body]

indexing_settings:
  commit_timeout_secs: 10
@reactima
Copy link
Author

reactima commented Apr 21, 2024

Overall quickwit-oss/quickwit-go needs to be completely re-written. It's in the first commit stage right now.

  1. starting from NewQuickwitClient error return and all error handing down the road
  2. not even close to be in sync with
    https://quickwit.io/docs/reference/rest-api
  3. better, smarter go way of handling schemes and corresponding Hits required. recent generic addition to golang might be useful

I haven't tested fully quickwit yet, but feel free to tag me on your lib for feedback if you are already advanced further.

P.s. quickwit itself and quickwit-oss/tantivy looks awesome ... and JVM based code is forbidden in my company ;)
Haven't seen anything close to compete with elastic/lucene and overpower it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant