# us.off-the-clock.searchRecords

> Posts, events, bookmarks, polls, documents, listings and reviews of one content space the viewer reads, matching every part of a query and every other condition given: an H3 cell, a radius around a point and a bookmark's domain. The query's words and phrases rank the results and its other parts filter them; the parts read are answered in read. Only records the viewer may see are answered, never another space's. SearchUnavailable is answered for mode=semantic before any other parameter is read, so a call without query tells a client whether meaning search is on.

- Kind: query
- Authority: off-the-clock.us
- Lexicon: 1
- Published by [off-the-clock.us](https://lexicon.garden/identity/did:plc:tevv7zpavtjtsvqrrwwipobt), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:tevv7zpavtjtsvqrrwwipobt/us.off-the-clock.searchRecords)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:tevv7zpavtjtsvqrrwwipobt/us.off-the-clock.searchRecords/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:tevv7zpavtjtsvqrrwwipobt/us.off-the-clock.searchRecords/analytics)

## Query (`us.off-the-clock.searchRecords`)

Type: query · GET

### Parameters (query string)

- `cursor` (string)
- `domain` (string): Bookmarks whose subject's host is this domain or a subdomain of it, case-insensitive.
  - Constraints: maxLength: 253
- `from` (string · datetime): Records sorted at or after this time.
- `h3` (string): An H3 cell index in hexadecimal, at resolution 4 to 10.
  - Constraints: maxLength: 16
- `limit` (integer)
  - Constraints: minimum: 1, maximum: 50, default: 25
- `mode` (string): best ranks full text and meaning together; keyword requires every word; text reads the words and phrases as a full-text query; semantic ranks by meaning.
  - Constraints: maxLength: 16, default: "best", knownValues: best | keyword | text | semantic
- `near` (string): A point as decimal degrees, latitude,longitude.
  - Constraints: maxLength: 64
- `query` (string): The search as a member typed it, read whole (D100): words, "phrases", rating:N/10, @handle, mentions:@handle, type:X (post, reply, event, bookmark, document, poll, listing or review), has:X and no:X (parent, replies, tags; has:mentions), and #tag, combined with AND. Required unless h3, near or domain is given.
  - Constraints: minLength: 1, maxLength: 300
- `space` (string · tid, required): The pair's TID.
- `until` (string · datetime): Records sorted before this time.
- `within` (string): The radius around near in kilometres, a decimal from 0.1 to 100; 5 by default.
  - Constraints: maxLength: 16

### Output (application/json)

- `cursor` (string)
- `hits` (array, required)
  - `items` (ref)
    - Reference: `#hit`
- `mapUrl` (string · uri): For a search by place: a signed map of this page's first ten hits, numbered in order (IMG-14), when a map provider is configured.
- `noPlaces` (boolean): True on a search by place that found nothing in a space where no record has a place yet.
- `read` (array, required): The parts of the query as they were read, in reading order.
  - `items` (ref)
    - Reference: `#part`

### Errors

- `InvalidRequest`: No description in schema.
- `NotSpaceMember`: No description in schema.
- `SearchUnavailable`: mode=semantic on a site with no embeddings endpoint.

## #hit (`us.off-the-clock.searchRecords#hit`)

Type: object

### Properties

- `distanceKm` (string): For near: the distance in kilometres from the point to the record's nearest place, a decimal.
  - Constraints: maxLength: 16
- `record` (union, required)
  - One of: `us.off-the-clock.defs#postView`, `us.off-the-clock.defs#eventView`, `us.off-the-clock.defs#bookmarkView`, `us.off-the-clock.defs#documentView`, `us.off-the-clock.defs#listingView`, `us.off-the-clock.defs#reviewView`, `us.off-the-clock.polls.pollView`
- `score` (string, required): The mode's own number as a decimal: BM25 made positive for keyword and text, cosine similarity for semantic, 0 for a search by place alone. Lexicons carry no floats.
  - Constraints: maxLength: 32
- `snippet` (string): The matched text with each match between [ and ].
  - Constraints: maxLength: 2000

## #part (`us.off-the-clock.searchRecords#part`)

Type: object

One part of a query as it was read: one word, a phrase without its quotes, a rating's number, a handle or DID without its @, a type's name, a statement's name, or a tag without its #.

### Properties

- `kind` (string, required)
  - Constraints: maxLength: 16, knownValues: words | phrase | rating | author | type | has | hasNo | mentions | tag
- `value` (string, required)
  - Constraints: maxLength: 300

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "hit": {
      "properties": {
        "distanceKm": {
          "description": "For near: the distance in kilometres from the point to the record's nearest place, a decimal.",
          "maxLength": 16,
          "type": "string"
        },
        "record": {
          "refs": [
            "us.off-the-clock.defs#postView",
            "us.off-the-clock.defs#eventView",
            "us.off-the-clock.defs#bookmarkView",
            "us.off-the-clock.defs#documentView",
            "us.off-the-clock.defs#listingView",
            "us.off-the-clock.defs#reviewView",
            "us.off-the-clock.polls.pollView"
          ],
          "type": "union"
        },
        "score": {
          "description": "The mode's own number as a decimal: BM25 made positive for keyword and text, cosine similarity for semantic, 0 for a search by place alone. Lexicons carry no floats.",
          "maxLength": 32,
          "type": "string"
        },
        "snippet": {
          "description": "The matched text with each match between [ and ].",
          "maxLength": 2000,
          "type": "string"
        }
      },
      "required": [
        "record",
        "score"
      ],
      "type": "object"
    },
    "main": {
      "description": "Posts, events, bookmarks, polls, documents, listings and reviews of one content space the viewer reads, matching every part of a query and every other condition given: an H3 cell, a radius around a point and a bookmark's domain. The query's words and phrases rank the results and its other parts filter them; the parts read are answered in read. Only records the viewer may see are answered, never another space's. SearchUnavailable is answered for mode=semantic before any other parameter is read, so a call without query tells a client whether meaning search is on.",
      "errors": [
        {
          "name": "InvalidRequest"
        },
        {
          "name": "NotSpaceMember"
        },
        {
          "description": "mode=semantic on a site with no embeddings endpoint.",
          "name": "SearchUnavailable"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "cursor": {
              "type": "string"
            },
            "hits": {
              "items": {
                "ref": "#hit",
                "type": "ref"
              },
              "type": "array"
            },
            "mapUrl": {
              "description": "For a search by place: a signed map of this page's first ten hits, numbered in order (IMG-14), when a map provider is configured.",
              "format": "uri",
              "type": "string"
            },
            "noPlaces": {
              "description": "True on a search by place that found nothing in a space where no record has a place yet.",
              "type": "boolean"
            },
            "read": {
              "description": "The parts of the query as they were read, in reading order.",
              "items": {
                "ref": "#part",
                "type": "ref"
              },
              "type": "array"
            }
          },
          "required": [
            "hits",
            "read"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "cursor": {
            "type": "string"
          },
          "domain": {
            "description": "Bookmarks whose subject's host is this domain or a subdomain of it, case-insensitive.",
            "maxLength": 253,
            "type": "string"
          },
          "from": {
            "description": "Records sorted at or after this time.",
            "format": "datetime",
            "type": "string"
          },
          "h3": {
            "description": "An H3 cell index in hexadecimal, at resolution 4 to 10.",
            "maxLength": 16,
            "type": "string"
          },
          "limit": {
            "default": 25,
            "maximum": 50,
            "minimum": 1,
            "type": "integer"
          },
          "mode": {
            "default": "best",
            "description": "best ranks full text and meaning together; keyword requires every word; text reads the words and phrases as a full-text query; semantic ranks by meaning.",
            "knownValues": [
              "best",
              "keyword",
              "text",
              "semantic"
            ],
            "maxLength": 16,
            "type": "string"
          },
          "near": {
            "description": "A point as decimal degrees, latitude,longitude.",
            "maxLength": 64,
            "type": "string"
          },
          "query": {
            "description": "The search as a member typed it, read whole (D100): words, \"phrases\", rating:N/10, @handle, mentions:@handle, type:X (post, reply, event, bookmark, document, poll, listing or review), has:X and no:X (parent, replies, tags; has:mentions), and #tag, combined with AND. Required unless h3, near or domain is given.",
            "maxLength": 300,
            "minLength": 1,
            "type": "string"
          },
          "space": {
            "description": "The pair's TID.",
            "format": "tid",
            "type": "string"
          },
          "until": {
            "description": "Records sorted before this time.",
            "format": "datetime",
            "type": "string"
          },
          "within": {
            "description": "The radius around near in kilometres, a decimal from 0.1 to 100; 5 by default.",
            "maxLength": 16,
            "type": "string"
          }
        },
        "required": [
          "space"
        ],
        "type": "params"
      },
      "type": "query"
    },
    "part": {
      "description": "One part of a query as it was read: one word, a phrase without its quotes, a rating's number, a handle or DID without its @, a type's name, a statement's name, or a tag without its #.",
      "properties": {
        "kind": {
          "knownValues": [
            "words",
            "phrase",
            "rating",
            "author",
            "type",
            "has",
            "hasNo",
            "mentions",
            "tag"
          ],
          "maxLength": 16,
          "type": "string"
        },
        "value": {
          "maxLength": 300,
          "type": "string"
        }
      },
      "required": [
        "kind",
        "value"
      ],
      "type": "object"
    }
  },
  "id": "us.off-the-clock.searchRecords",
  "lexicon": 1
}
```
