Lightspeed search built for devs | Don MacKinnon on the future of content search

Spent the day working through Lightspeed search built for devs | Don MacKinnon on the future of content search, this episode of the changelog about searchcraft. It was really interesting,

Then found this demo loading all of wikipedia and getting really sick search results out of it!

https://www.youtube.com/watch?v=SjuPn6_yl2s



podman run --name searchcraft -p 8000:8000 searchcraftinc/searchcraft-core:latest

# create an index
curl -X POST -H "Content-Type: application/json" --data '
{
  "index": {
    "name": "creation_test",
    "search_fields": [
      "title",
      "body"
    ],
    "fields": {
      "id": {
        "type": "text",
        "required": true,
        "stored": true,
        "indexed": false
      },
      "created_at": {
        "type": "datetime",
        "fast": true,
        "stored": true,
        "indexed": true
      },
      "title": {
        "type": "text",
        "stored": true
      },
      "body": {
        "type": "text",
        "stored": true
      },
      "active": {
        "type": "bool",
        "fast": true,
        "stored": true
      },
      "rating": {
        "type": "f64",
        "stored": true,
        "fast": true
      },
      "reviews": {
        "type": "u64",
        "stored": true,
        "fast": true
      },
      "tags": {
        "type": "text",
        "stored": true,
        "multi": true
      },
      "category": {
        "type": "facet",
        "stored": true
      },
      "formats": {
        "type": "facet",
        "stored": true,
        "multi": true
      }
    },
    "weight_multipliers": {
      "title": 2,
      "body": 0.7
    }
  }
}
' http://0.0.0.0:8000/index


# put a document in the index
curl -X POST -H "Content-Type: application/json"   --data '{
    "document": {
      "id": "doc-001",
      "created_at": "2024-07-10T12:00:00Z",
      "title": "Hello World",
      "body": "This is your first Searchcraft document!",
      "url": "https://searchcraft.com",
      "active": true,
      "rating": 4.5,
      "reviews": 3,
      "tags": ["demo", "test"],
      "category": "/demo",
      "formats": ["/pdf", "/markdown"]
    }
  }' http://0.0.0.0:8000/document/creation_test

# commit the changes
curl -X POST http://0.0.0.0:8000/index/creation_test/commit

## search
curl -X POST -H "Content-Type: application/json" --data '{
  "limit": 5,
  "offset": 0,
  "query": {
    "fuzzy": {
      "ctx": "searchcraft"
    }
  }
}' http://0.0.0.0:8000/index/creation_test/search

results


{
  "status": 200,
  "data": {
    "hits": [
      {
        "doc": {
          "id": "doc-001",
          "formats": [
            "/pdf",
            "/markdown"
          ],
          "active": true,
          "reviews": 3,
          "tags": [
            "demo",
            "test"
          ],
          "created_at": "2024-07-10T12:00:00Z",
          "category": "/demo",
          "rating": 4.5,
          "title": "Hello World",
          "body": "This is your first Searchcraft document!"
        },
        "document_id": "13964682816361504761",
        "score": 0.90137744,
        "source_index": "creation_test"
      }
    ],
    "count": 1,
    "time_taken": 0.000679577,
    "facets": [
      {
        "category": [
          {
            "path": "/demo",
            "count": 1
          }
        ]
      },
      {
        "formats": [
          {
            "path": "/markdown",
            "count": 1
          },
          {
            "path": "/pdf",
            "count": 1
          }
        ]
      }
    ]
  }
}