-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (100 loc) · 3.56 KB
/
Makefile
File metadata and controls
122 lines (100 loc) · 3.56 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
.PHONY: help
help: ## Display this help message
@echo "CSV to OpenSearch Indexer - Available Commands"
@echo "=============================================="
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: deps
deps: ## Download Go dependencies
@echo "Downloading Go dependencies..."
go mod download
go mod tidy
.PHONY: build
build: deps ## Build the application
@echo "Building application..."
go build -o bin/csv-indexer cmd/main.go
.PHONY: run
run: ## Run the application with sample data
go run cmd/main.go -csv data/sample.csv
.PHONY: run-skip-tika
run-skip-tika: ## Run the application without Tika parsing
go run cmd/main.go -csv data/sample.csv -skip-tika
.PHONY: docker-up
docker-up: ## Start OpenSearch and Tika containers
@echo "Starting Docker containers..."
docker-compose up -d
@echo "Waiting for services to be ready..."
@sleep 10
@echo "Services should be available at:"
@echo " - OpenSearch: http://localhost:9200"
@echo " - OpenSearch Dashboards: http://localhost:5601"
@echo " - Tika Server: http://localhost:9998"
.PHONY: docker-down
docker-down: ## Stop and remove Docker containers
@echo "Stopping Docker containers..."
docker-compose down
.PHONY: docker-clean
docker-clean: ## Stop containers and remove volumes
@echo "Stopping containers and removing volumes..."
docker-compose down -v
.PHONY: docker-logs
docker-logs: ## Show Docker container logs
docker-compose logs -f
.PHONY: docker-ps
docker-ps: ## Show Docker container status
docker-compose ps
.PHONY: test-opensearch
test-opensearch: ## Test OpenSearch connection
@echo "Testing OpenSearch connection..."
@curl -s http://localhost:9200 | jq '.' || echo "OpenSearch not available. Run 'make docker-up' first."
.PHONY: test-tika
test-tika: ## Test Tika server connection
@echo "Testing Tika server connection..."
@curl -s http://localhost:9998/version | jq '.' || echo "Tika not available. Run 'make docker-up' first."
.PHONY: search
search: ## Search indexed documents (requires jq)
@read -p "Enter search query: " query; \
curl -s -X GET "http://localhost:9200/csv-documents/_search" \
-H 'Content-Type: application/json' \
-d '{"query": {"multi_match": {"query": "'$$query'", "fields": ["content", "metadata.*"]}}}' \
| jq '.'
.PHONY: list-indices
list-indices: ## List all OpenSearch indices
@echo "OpenSearch indices:"
@curl -s http://localhost:9200/_cat/indices?v
.PHONY: delete-index
delete-index: ## Delete the csv-documents index
@echo "Deleting csv-documents index..."
@curl -X DELETE http://localhost:9200/csv-documents
@echo ""
.PHONY: clean-output
clean-output: ## Clean generated XML files
@echo "Cleaning output directory..."
rm -rf output/*.xml
.PHONY: clean
clean: clean-output ## Clean all generated files
@echo "Cleaning all generated files..."
rm -rf bin/
rm -rf output/
.PHONY: full-run
full-run: docker-up build ## Start services, build, and run with sample data
@echo "Waiting for services to be ready..."
@sleep 15
./bin/csv-indexer -csv data/sample.csv
.PHONY: full-clean
full-clean: docker-clean clean ## Complete cleanup of containers, volumes, and files
@echo "Complete cleanup done!"
.PHONY: fmt
fmt: ## Format Go code
@echo "Formatting Go code..."
go fmt ./...
.PHONY: vet
vet: ## Run Go vet
@echo "Running go vet..."
go vet ./...
.PHONY: lint
lint: fmt vet ## Run formatters and linters
@echo "Code linting complete!"
.PHONY: install
install: build ## Install the binary to GOPATH/bin
@echo "Installing csv-indexer to GOPATH/bin..."
go install ./cmd/main.go