Skip to content

Commit

Permalink
Query Processor V2
Browse files Browse the repository at this point in the history
  • Loading branch information
mieciu committed Dec 18, 2024
1 parent 907d92a commit 3d338fe
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
17 changes: 9 additions & 8 deletions quesma/frontend_connectors/elasticsearch_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package frontend_connectors
import (
"context"
"net/http"
"quesma/quesma/config"
quesma_api "quesma_v2/core"
)

Expand Down Expand Up @@ -34,15 +35,15 @@ const ( // taken from `router.go`
SearchIndexTargetKey = "search_index_target"
)

func NewElasticsearchQueryFrontendConnector(endpoint string) *ElasticsearchQueryFrontendConnector {
func NewElasticsearchQueryFrontendConnector(endpoint string, cfg *config.QuesmaConfiguration) *ElasticsearchQueryFrontendConnector {

basicHttpFrontendConnector := NewBasicHTTPFrontendConnector(endpoint, cfg)
basicHttpFrontendConnector.responseMutator = func(w http.ResponseWriter) http.ResponseWriter {
w.Header().Set("Content-Type", "application/json")
return w
}
fc := &ElasticsearchQueryFrontendConnector{
BasicHTTPFrontendConnector: BasicHTTPFrontendConnector{
endpoint: endpoint,
responseMutator: func(w http.ResponseWriter) http.ResponseWriter {
w.Header().Set("Content-Type", "application/json")
return w
},
},
BasicHTTPFrontendConnector: *basicHttpFrontendConnector,
}
router := quesma_api.NewPathRouter()
router.AddRoute(IndexSearchPath, searchHandler)
Expand Down
4 changes: 4 additions & 0 deletions quesma/frontend_connectors/router_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ func (r *RouterV2) Reroute(ctx context.Context, w http.ResponseWriter, req *http
}
metadata, message := dispatcher.Dispatch(handlersPipe.Processors, result.Meta, result.GenericResult)

if res, ok := message.(*quesma_api.Result); ok {
return res, nil
}

result = &quesma_api.Result{
Body: result.Body,
Meta: metadata,
Expand Down
11 changes: 10 additions & 1 deletion quesma/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ func buildIngestOnlyQuesma() quesma_api.QuesmaBuilder {
func buildQueryOnlyQuesma() quesma_api.QuesmaBuilder {
var quesmaBuilder quesma_api.QuesmaBuilder = quesma_api.NewQuesma()
quesmaBuilder.SetDependencies(quesma_api.EmptyDependencies())
queryFrontendConnector := frontend_connectors.NewElasticsearchQueryFrontendConnector(":8080")
queryFrontendConnector := frontend_connectors.NewElasticsearchQueryFrontendConnector(
":8080",
&config.QuesmaConfiguration{
DisableAuth: true,
Elasticsearch: config.ElasticsearchConfiguration{
Url: &config.Url{Host: "localhost:9200", Scheme: "http"},
User: "",
Password: "",
},
})

var queryPipeline quesma_api.PipelineBuilder = quesma_api.NewPipeline()
queryPipeline.AddFrontendConnector(queryFrontendConnector)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func (p *ElasticsearchToClickHouseQueryProcessor) Handle(metadata map[string]int
switch findQueryTarget(indexNameFromIncomingReq, p.config) {
case config.ClickhouseTarget:
res, _ := quesm.HandleIndexSearch2(context.Background(), quesmaReq, p.queryRunner)

return metadata, res, nil
case config.ElasticsearchTarget:
println("POSZLO DO ELASTICSEARCHA ")
Expand Down

0 comments on commit 3d338fe

Please sign in to comment.