Skip to content

Add Full-Text Search for Transactions, Users, and Tags with Elasticsearch #335

@llinsss

Description

@llinsss

Problem

Current search is basic SQL queries with limited capabilities. Need advanced full-text search with fuzzy matching, filters, and fast performance.

Proposed Solution

Integrate Elasticsearch for advanced search capabilities across transactions, users, tags, and invoices.

Technical Implementation

New Files:

  • backend/services/ElasticsearchService.js - Elasticsearch service
  • backend/services/search/IndexManager.js - Index management
  • backend/services/search/QueryBuilder.js - Query builder
  • backend/services/search/TransactionSearchService.js - Transaction search
  • backend/services/search/UserSearchService.js - User search
  • backend/services/search/TagSearchService.js - Tag search
  • backend/controllers/searchController.js - Search endpoints
  • backend/routes/search.js - Search routes
  • backend/workers/elasticsearchSync.js - Data sync worker
  • backend/config/elasticsearch.js - ES configuration
  • backend/tests/elasticsearch.test.js - Test suite

Modify:

  • backend/services/TransactionSearchService.js - Use Elasticsearch
  • backend/controllers/transactionController.js - Add advanced search
  • backend/models/Transaction.js - Add ES sync hooks
  • backend/models/User.js - Add ES sync hooks
  • backend/.env.example - Add Elasticsearch URL

Index Mappings

const transactionIndex = {
  mappings: {
    properties: {
      transaction_id: { type: 'keyword' },
      from_tag: { type: 'text', analyzer: 'standard' },
      to_tag: { type: 'text', analyzer: 'standard' },
      amount: { type: 'double' },
      currency: { type: 'keyword' },
      chain: { type: 'keyword' },
      status: { type: 'keyword' },
      created_at: { type: 'date' },
      description: { type: 'text', analyzer: 'english' }
    }
  }
};

Search API

POST /api/search/transactions
Body: {
  query: "john payment",
  filters: {
    chain: ["base", "starknet"],
    status: ["completed"],
    dateRange: {
      from: "2025-01-01",
      to: "2025-01-31"
    },
    amountRange: {
      min: 100,
      max: 1000
    }
  },
  sort: { field: "created_at", order: "desc" },
  page: 1,
  limit: 20
}

Acceptance Criteria

  • Elasticsearch integration with Docker
  • Indexes for transactions, users, tags, invoices
  • Full-text search with fuzzy matching
  • Advanced filtering and sorting
  • Pagination and aggregations
  • Real-time data sync
  • Search suggestions/autocomplete
  • Test coverage > 80%

Priority

Medium - Significant UX improvement


Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions