Skip to content

About

FastAPI service for searching Life365 products

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

life365-search

FastAPI service for searching Life365 products.

Search entry points samples

Base URL: http://localhost:8000

/search response includes:

  • total, page, page_size, results
  • groups.brand: a map {brand_name: matched_count} computed over all matched documents for the query+filters (not only the current page)
  • groups.category_level_1|2|3: maps {category_id: matched_count}
  • groups.type1|type2: maps {type_value: matched_count}

/search supported query parameters

Param Type Default Constraints
q string | null null Full-text query
category_level_1 int | null null
category_level_2 int | null null
category_level_3 int | null null
brand string | null null
available bool true
visible bool true
page int 1 >= 1
page_size int 20 >= 1, <= 100
lang enum it it, en, cn
sort enum relevance relevance, newest, brand

sort values behavior

  • relevance: sorts by OpenSearch _score (best text match first). Scoring uses title (higher boost), keywords, description, and category title in the selected language.
  • newest: sorts by created_at descending (most recent first).
  • brand: sorts by brand ascending (A to Z) using exact keyword values.

Notes:

  • Filters (category_level_*, brand, available, visible) limit which products are returned, but do not change text relevance scoring.
  • If q is omitted, the query is match_all; with sort=relevance, ordering is not meaningful by relevance.

Health check

curl -s http://localhost:8000/health

Basic full-text search

curl -sG http://localhost:8000/search --data-urlencode "q=pellicola"

Example response excerpt:

{
  "total": 110,
  "page": 1,
  "page_size": 20,
  "results": [
    {
      "product_id": 16453,
      "title": "Toner compa 2310,2350,2370,2375,2510,2530,2550,2730,2750-3K",
      "brand": "Pro-Brother",
      "is_available": true
    }
  ],
  "groups": {
    "brand": {
      "Pro-Brother": 6,
      "Pro-Canon": 4
    },
    "category_level_1": {
      "1": 39,
      "14": 2
    },
    "category_level_2": {
      "188": 20
    },
    "category_level_3": {
      "1134": 12
    },
    "type1": {
      "200W": 1,
      "250W": 2,
      "Blue-White": 1
    },
    "type2": {
      "200W": 1,
      "250W": 2,
      "Blue-White": 1
    }
  }
}

Exact search by ISIN

curl -sG http://localhost:8000/search --data-urlencode "q=DETPUPD03228"

Exact search by barcode

curl -sG http://localhost:8000/search --data-urlencode "q=6938595306273"

Search with category and brand filters

curl -sG http://localhost:8000/search \
  --data-urlencode "q=iphone" \
  --data-urlencode "category_level_1=1" \
  --data-urlencode "category_level_2=2" \
  --data-urlencode "brand=Devia"

Search with language, paging, and sort

curl -sG http://localhost:8000/search \
  --data-urlencode "q=cover" \
  --data-urlencode "lang=en" \
  --data-urlencode "page=2" \
  --data-urlencode "page_size=10" \
  --data-urlencode "sort=newest"

Trigger full reindex

curl -sX POST http://localhost:8000/admin/reindex

When running with docker-compose, the scheduler service also triggers app.infrastructure.celery.tasks.reindex_all_task automatically every 6 hours using the schedule defined in worker/reindex.cron.

About

FastAPI service for searching Life365 products

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages