2016-07-12 18:22:33 +02:00
|
|
|
# Copyright 2016 OpenMarket Ltd
|
|
|
|
|
#
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
2015-10-14 15:19:11 +02:00
|
|
|
swagger: '2.0'
|
|
|
|
|
info:
|
2015-12-04 12:09:35 +01:00
|
|
|
title: "Matrix Client-Server Search API"
|
2015-10-14 15:19:11 +02:00
|
|
|
version: "1.0.0"
|
|
|
|
|
host: localhost:8008
|
|
|
|
|
schemes:
|
|
|
|
|
- https
|
|
|
|
|
- http
|
2021-10-12 19:07:01 +02:00
|
|
|
basePath: /_matrix/client/v3
|
2015-10-14 15:19:11 +02:00
|
|
|
consumes:
|
|
|
|
|
- application/json
|
|
|
|
|
produces:
|
|
|
|
|
- application/json
|
|
|
|
|
securityDefinitions:
|
2016-05-03 14:57:16 +02:00
|
|
|
$ref: definitions/security.yaml
|
2015-10-14 15:19:11 +02:00
|
|
|
paths:
|
|
|
|
|
"/search":
|
|
|
|
|
post:
|
2015-12-17 14:40:22 +01:00
|
|
|
summary: Perform a server-side search.
|
2015-10-14 15:19:11 +02:00
|
|
|
description: |-
|
|
|
|
|
Performs a full text search across different categories.
|
2017-08-03 01:19:34 +02:00
|
|
|
operationId: search
|
2015-10-14 15:19:11 +02:00
|
|
|
security:
|
|
|
|
|
- accessToken: []
|
|
|
|
|
parameters:
|
2015-12-17 14:40:22 +01:00
|
|
|
- in: query
|
|
|
|
|
name: next_batch
|
|
|
|
|
type: string
|
|
|
|
|
description: |-
|
|
|
|
|
The point to return events from. If given, this should be a
|
2021-01-27 21:14:31 +01:00
|
|
|
`next_batch` result from a previous call to this endpoint.
|
2015-12-17 14:40:22 +01:00
|
|
|
x-example: "YWxsCgpOb25lLDM1ODcwOA"
|
2015-10-14 15:19:11 +02:00
|
|
|
- in: body
|
|
|
|
|
name: body
|
2020-05-25 19:08:17 +02:00
|
|
|
required: true
|
2015-10-14 15:19:11 +02:00
|
|
|
schema:
|
|
|
|
|
type: object
|
2017-09-26 18:53:28 +02:00
|
|
|
example: {
|
2015-10-14 15:19:11 +02:00
|
|
|
"search_categories": {
|
|
|
|
|
"room_events": {
|
|
|
|
|
"keys": [
|
|
|
|
|
"content.body"
|
|
|
|
|
],
|
2018-06-05 11:12:34 +02:00
|
|
|
"search_term": "martians and men",
|
|
|
|
|
"order_by": "recent",
|
|
|
|
|
"groupings": {
|
|
|
|
|
"group_by": [
|
|
|
|
|
{
|
|
|
|
|
"key": "room_id"
|
|
|
|
|
}
|
|
|
|
|
]
|
2015-11-16 17:04:23 +01:00
|
|
|
}
|
2018-06-05 11:12:34 +02:00
|
|
|
}
|
2015-10-14 15:19:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
properties:
|
|
|
|
|
search_categories:
|
|
|
|
|
type: object
|
2015-10-14 16:01:21 +02:00
|
|
|
title: "Categories"
|
2015-10-14 15:19:11 +02:00
|
|
|
description: Describes which categories to search in and
|
2015-10-15 16:51:02 +02:00
|
|
|
their criteria.
|
2015-10-14 15:19:11 +02:00
|
|
|
properties:
|
|
|
|
|
room_events:
|
|
|
|
|
type: object
|
2018-05-03 16:19:55 +02:00
|
|
|
title: Room Events Criteria
|
2015-10-14 15:19:11 +02:00
|
|
|
description: Mapping of category name to search criteria.
|
|
|
|
|
properties:
|
|
|
|
|
search_term:
|
|
|
|
|
type: string
|
|
|
|
|
description: The string to search events for
|
|
|
|
|
keys:
|
|
|
|
|
type: array
|
|
|
|
|
items:
|
|
|
|
|
type: string
|
|
|
|
|
enum: ["content.body", "content.name", "content.topic"]
|
|
|
|
|
description: The keys to search. Defaults to all.
|
2015-10-26 11:18:40 +01:00
|
|
|
filter:
|
|
|
|
|
type: object
|
|
|
|
|
title: Filter
|
|
|
|
|
description: |-
|
2021-01-29 01:00:39 +01:00
|
|
|
This takes a [filter](/client-server-api/#filtering).
|
2020-05-25 20:40:00 +02:00
|
|
|
allOf:
|
|
|
|
|
- $ref: "definitions/room_event_filter.yaml"
|
2015-11-16 17:04:23 +01:00
|
|
|
order_by:
|
|
|
|
|
title: "Ordering"
|
|
|
|
|
type: string
|
|
|
|
|
enum: ["recent", "rank"]
|
2018-01-30 15:29:59 +01:00
|
|
|
description: |-
|
|
|
|
|
The order in which to search for results.
|
2021-01-27 21:14:31 +01:00
|
|
|
By default, this is `"rank"`.
|
2015-11-16 17:04:23 +01:00
|
|
|
event_context:
|
2018-07-05 18:46:53 +02:00
|
|
|
title: Include Event Context
|
2015-11-16 17:04:23 +01:00
|
|
|
type: object
|
|
|
|
|
description: |-
|
|
|
|
|
Configures whether any context for the events
|
|
|
|
|
returned are included in the response.
|
|
|
|
|
properties:
|
|
|
|
|
before_limit:
|
|
|
|
|
type: integer
|
|
|
|
|
title: "Before limit"
|
|
|
|
|
description: |-
|
|
|
|
|
How many events before the result are
|
2021-01-27 21:14:31 +01:00
|
|
|
returned. By default, this is `5`.
|
2015-11-16 17:04:23 +01:00
|
|
|
after_limit:
|
|
|
|
|
type: integer
|
|
|
|
|
title: "After limit"
|
|
|
|
|
description: |-
|
|
|
|
|
How many events after the result are
|
2021-01-27 21:14:31 +01:00
|
|
|
returned. By default, this is `5`.
|
2015-11-20 16:29:36 +01:00
|
|
|
include_profile:
|
|
|
|
|
type: boolean
|
|
|
|
|
title: "Return profile information"
|
|
|
|
|
description: |-
|
|
|
|
|
Requests that the server returns the
|
|
|
|
|
historic profile information for the users
|
|
|
|
|
that sent the events that were returned.
|
2021-01-27 21:14:31 +01:00
|
|
|
By default, this is `false`.
|
2015-11-20 16:29:36 +01:00
|
|
|
include_state:
|
|
|
|
|
type: boolean
|
|
|
|
|
title: Include current state
|
|
|
|
|
description: |-
|
|
|
|
|
Requests the server return the current state for
|
|
|
|
|
each room returned.
|
2015-11-16 17:04:23 +01:00
|
|
|
groupings:
|
|
|
|
|
type: object
|
|
|
|
|
title: Groupings
|
|
|
|
|
description: |-
|
2015-12-07 17:06:25 +01:00
|
|
|
Requests that the server partitions the result set
|
|
|
|
|
based on the provided list of keys.
|
2015-11-16 17:04:23 +01:00
|
|
|
properties:
|
|
|
|
|
group_by:
|
|
|
|
|
type: array
|
|
|
|
|
title: Groups
|
|
|
|
|
description: List of groups to request.
|
|
|
|
|
items:
|
|
|
|
|
type: object
|
|
|
|
|
title: Group
|
|
|
|
|
description: Configuration for group.
|
|
|
|
|
properties:
|
|
|
|
|
key:
|
|
|
|
|
type: string
|
|
|
|
|
title: Group Key
|
2016-05-04 15:55:43 +02:00
|
|
|
description: |-
|
2015-11-16 17:04:23 +01:00
|
|
|
Key that defines the group.
|
|
|
|
|
enum: ["room_id", "sender"]
|
2015-10-14 15:19:11 +02:00
|
|
|
required: ["search_term"]
|
|
|
|
|
required: ["search_categories"]
|
|
|
|
|
responses:
|
|
|
|
|
200:
|
|
|
|
|
description: Results of the search.
|
|
|
|
|
schema:
|
|
|
|
|
type: object
|
2015-10-14 15:35:08 +02:00
|
|
|
title: Results
|
2015-10-14 15:19:11 +02:00
|
|
|
required: ["search_categories"]
|
|
|
|
|
properties:
|
|
|
|
|
search_categories:
|
|
|
|
|
type: object
|
2018-05-03 16:19:55 +02:00
|
|
|
title: Result Categories
|
2015-10-14 15:19:11 +02:00
|
|
|
description: Describes which categories to search in and
|
2015-10-15 16:51:02 +02:00
|
|
|
their criteria.
|
2015-10-14 15:19:11 +02:00
|
|
|
properties:
|
|
|
|
|
room_events:
|
|
|
|
|
type: object
|
2018-05-03 16:19:55 +02:00
|
|
|
title: Result Room Events
|
2015-10-14 15:19:11 +02:00
|
|
|
description: Mapping of category name to search criteria.
|
|
|
|
|
properties:
|
|
|
|
|
count:
|
2018-08-27 05:30:33 +02:00
|
|
|
type: integer
|
2015-12-11 12:41:51 +01:00
|
|
|
description: An approximate count of the total number of results found.
|
2018-06-05 11:06:26 +02:00
|
|
|
highlights:
|
|
|
|
|
type: array
|
|
|
|
|
title: Highlights
|
|
|
|
|
description: List of words which should be highlighted, useful for stemming which may change the query terms.
|
|
|
|
|
items:
|
|
|
|
|
type: string
|
2015-10-14 15:19:11 +02:00
|
|
|
results:
|
2015-12-01 16:33:13 +01:00
|
|
|
type: array
|
2015-10-14 15:35:08 +02:00
|
|
|
title: Results
|
2015-12-01 16:34:25 +01:00
|
|
|
description: List of results in the requested order.
|
2015-12-01 16:33:13 +01:00
|
|
|
items:
|
2015-10-14 15:19:11 +02:00
|
|
|
type: object
|
2015-10-14 15:35:08 +02:00
|
|
|
title: Result
|
2015-10-14 16:35:39 +02:00
|
|
|
description: The result object.
|
2015-10-14 15:19:11 +02:00
|
|
|
properties:
|
|
|
|
|
rank:
|
2018-08-28 19:01:43 +02:00
|
|
|
type: number
|
2015-10-14 15:19:11 +02:00
|
|
|
description: A number that describes how closely
|
|
|
|
|
this result matches the search. Higher is
|
|
|
|
|
closer.
|
|
|
|
|
result:
|
2015-11-16 18:22:56 +01:00
|
|
|
type: object
|
|
|
|
|
title: Event
|
|
|
|
|
description: The event that matched.
|
2023-03-07 17:51:30 +01:00
|
|
|
allOf:
|
|
|
|
|
- "$ref": "definitions/client_event.yaml"
|
2015-11-16 18:22:56 +01:00
|
|
|
context:
|
|
|
|
|
type: object
|
|
|
|
|
title: Event Context
|
|
|
|
|
description: Context for result, if requested.
|
|
|
|
|
properties:
|
|
|
|
|
start:
|
|
|
|
|
type: string
|
|
|
|
|
title: Start Token
|
|
|
|
|
description: |-
|
|
|
|
|
Pagination token for the start of the chunk
|
|
|
|
|
end:
|
|
|
|
|
type: string
|
|
|
|
|
title: End Token
|
|
|
|
|
description: |-
|
|
|
|
|
Pagination token for the end of the chunk
|
2015-11-20 16:29:36 +01:00
|
|
|
profile_info:
|
|
|
|
|
type: object
|
|
|
|
|
title: Profile Information
|
|
|
|
|
description: |-
|
|
|
|
|
The historic profile information of the
|
|
|
|
|
users that sent the events returned.
|
2018-07-10 23:08:28 +02:00
|
|
|
|
2021-01-27 21:14:31 +01:00
|
|
|
The `string` key is the user ID for which
|
2018-07-10 23:08:28 +02:00
|
|
|
the profile belongs to.
|
2015-11-20 16:29:36 +01:00
|
|
|
additionalProperties:
|
|
|
|
|
type: object
|
|
|
|
|
title: User Profile
|
|
|
|
|
properties:
|
|
|
|
|
displayname:
|
|
|
|
|
type: string
|
|
|
|
|
title: Display name
|
|
|
|
|
avatar_url:
|
|
|
|
|
type: string
|
2021-08-09 08:54:34 +02:00
|
|
|
format: uri
|
2015-11-20 16:29:36 +01:00
|
|
|
title: Avatar Url
|
2015-11-16 18:22:56 +01:00
|
|
|
events_before:
|
|
|
|
|
type: array
|
|
|
|
|
title: Events Before
|
|
|
|
|
description: Events just before the result.
|
|
|
|
|
items:
|
|
|
|
|
title: Event
|
2016-05-04 15:55:43 +02:00
|
|
|
type: object
|
2022-02-01 16:05:08 +01:00
|
|
|
"$ref": "definitions/client_event.yaml"
|
2015-11-16 18:22:56 +01:00
|
|
|
events_after:
|
|
|
|
|
type: array
|
|
|
|
|
title: Events After
|
2015-11-16 19:00:48 +01:00
|
|
|
description: Events just after the result.
|
2015-11-16 18:22:56 +01:00
|
|
|
items:
|
|
|
|
|
title: Event
|
2016-05-04 15:55:43 +02:00
|
|
|
type: object
|
2022-02-01 16:05:08 +01:00
|
|
|
"$ref": "definitions/client_event.yaml"
|
2015-11-20 16:29:36 +01:00
|
|
|
state:
|
|
|
|
|
type: object
|
|
|
|
|
title: Current state
|
2015-12-08 14:37:32 +01:00
|
|
|
description: |-
|
|
|
|
|
The current state for every room in the results.
|
2015-12-08 16:35:59 +01:00
|
|
|
This is included if the request had the
|
2021-01-27 21:14:31 +01:00
|
|
|
`include_state` key set with a value of `true`.
|
2018-07-10 23:08:28 +02:00
|
|
|
|
2021-01-27 21:14:31 +01:00
|
|
|
The `string` key is the room ID for which the `State
|
|
|
|
|
Event` array belongs to.
|
2015-11-20 16:29:36 +01:00
|
|
|
additionalProperties:
|
|
|
|
|
type: array
|
|
|
|
|
title: Room State
|
|
|
|
|
items:
|
2022-02-01 16:05:08 +01:00
|
|
|
"$ref": "definitions/client_event.yaml"
|
2015-11-16 18:22:56 +01:00
|
|
|
groups:
|
|
|
|
|
type: object
|
|
|
|
|
title: Groups
|
2018-07-10 23:08:28 +02:00
|
|
|
description: |-
|
|
|
|
|
Any groups that were requested.
|
|
|
|
|
|
2021-01-27 21:14:31 +01:00
|
|
|
The outer `string` key is the group key requested (eg: `room_id`
|
|
|
|
|
or `sender`). The inner `string` key is the grouped value (eg:
|
2018-07-10 23:08:28 +02:00
|
|
|
a room's ID or a user's ID).
|
2015-11-16 18:22:56 +01:00
|
|
|
additionalProperties:
|
|
|
|
|
type: object
|
|
|
|
|
title: Group Key
|
|
|
|
|
description: The results for a given group.
|
|
|
|
|
additionalProperties:
|
|
|
|
|
type: object
|
|
|
|
|
title: Group Value
|
|
|
|
|
description: |-
|
|
|
|
|
The results for a particular group value.
|
|
|
|
|
properties:
|
|
|
|
|
next_batch:
|
|
|
|
|
type: string
|
|
|
|
|
title: Next Batch in Group
|
|
|
|
|
description: |-
|
2015-12-17 14:40:22 +01:00
|
|
|
Token that can be used to get the next batch
|
|
|
|
|
of results in the group, by passing as the
|
|
|
|
|
`next_batch` parameter to the next call. If
|
|
|
|
|
this field is absent, there are no more
|
|
|
|
|
results in this group.
|
2015-11-16 18:22:56 +01:00
|
|
|
order:
|
|
|
|
|
type: integer
|
|
|
|
|
title: Group Order
|
|
|
|
|
description: |-
|
|
|
|
|
Key that can be used to order different
|
|
|
|
|
groups.
|
|
|
|
|
results:
|
|
|
|
|
type: array
|
|
|
|
|
description: |-
|
|
|
|
|
Which results are in this group.
|
|
|
|
|
items:
|
|
|
|
|
type: string
|
|
|
|
|
title: Result Event ID
|
2015-11-17 11:02:02 +01:00
|
|
|
next_batch:
|
|
|
|
|
type: string
|
|
|
|
|
title: Next Batch
|
|
|
|
|
description: |-
|
|
|
|
|
Token that can be used to get the next batch of
|
2015-12-17 14:40:22 +01:00
|
|
|
results, by passing as the `next_batch` parameter to
|
|
|
|
|
the next call. If this field is absent, there are no
|
|
|
|
|
more results.
|
2015-10-14 15:19:11 +02:00
|
|
|
examples:
|
2017-09-26 18:53:28 +02:00
|
|
|
application/json: {
|
2015-10-14 15:19:11 +02:00
|
|
|
"search_categories": {
|
|
|
|
|
"room_events": {
|
2015-11-16 19:00:48 +01:00
|
|
|
"groups": {
|
|
|
|
|
"room_id": {
|
|
|
|
|
"!qPewotXpIctQySfjSy:localhost": {
|
|
|
|
|
"order": 1,
|
|
|
|
|
"next_batch": "BdgFsdfHSf-dsFD",
|
|
|
|
|
"results": [
|
|
|
|
|
"$144429830826TWwbB:localhost"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2018-06-05 11:10:24 +02:00
|
|
|
"highlights": [
|
|
|
|
|
"martians",
|
|
|
|
|
"men"
|
|
|
|
|
],
|
2015-12-07 16:54:08 +01:00
|
|
|
"next_batch": "5FdgFsd234dfgsdfFD",
|
2015-12-11 11:53:22 +01:00
|
|
|
"count": 1224,
|
2015-12-01 16:33:13 +01:00
|
|
|
"results": [
|
|
|
|
|
{
|
2015-10-14 15:19:11 +02:00
|
|
|
"rank": 0.00424866,
|
|
|
|
|
"result": {
|
|
|
|
|
"room_id": "!qPewotXpIctQySfjSy:localhost",
|
2019-05-29 22:56:42 +02:00
|
|
|
"event_id": "$144429830826TWwbB:localhost",
|
2021-01-26 06:16:42 +01:00
|
|
|
"$ref": "../../event-schemas/examples/m.room.message$m.text.yaml"
|
2015-10-14 15:19:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-12-01 16:33:13 +01:00
|
|
|
]
|
2015-10-14 15:19:11 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-10-16 11:26:14 +02:00
|
|
|
400:
|
|
|
|
|
description: Part of the request was invalid.
|
|
|
|
|
429:
|
|
|
|
|
description: This request was rate-limited.
|
|
|
|
|
schema:
|
2018-07-04 21:45:34 +02:00
|
|
|
"$ref": "definitions/errors/rate_limited.yaml"
|
2015-12-07 13:45:13 +01:00
|
|
|
tags:
|
|
|
|
|
- Search
|