From fa1938b104995fd718dab50d74d59512a4d74140 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Mon, 22 Oct 2018 09:59:12 +0200 Subject: [PATCH 1/2] Added content type filter Added claim type filter --- server/controllers/lighthouse.js | 27 +++++++++++++++++++++++++-- server/routes/lighthouse.js | 3 +++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 6eb8578..11c08dc 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -255,14 +255,37 @@ function getAutoCompleteQuery (query) { }; function getFilters (input) { - // this is the best place for putting things like filtering on the type of content - // Perhaps we can add search param that will filter on how people have categorized / tagged their content var filters = []; var bidStateFilter = {'bool': {'must_not': {'match': { 'bid_state': 'Accepted' }}}}; if (input.nsfw === 'true' || input.nsfw === 'false') { const nsfwFilter = {'match': {'value.stream.metadata.nsfw': input.nsfw}}; filters.push(nsfwFilter); } + if (input.contentType !== undefined) { + const contentFilter = {'match_phrase': {'value.stream.source.contentType': getEscapedQuery(input.contentType)}}; + filters.push(contentFilter); + } + if (input.mediaType !== undefined) { + const mediaTypes = ['audio', 'video', 'text', 'application', 'image']; + if (mediaTypes.includes(input.mediaType)) { + const mediaFilter = {'match_phrase_prefix': {'value.stream.source.contentType': input.mediaType + '\\/'}}; + filters.push(mediaFilter); + } else if (input.mediaType === 'cad') { + const cadTypes = ['SKP', 'simplify3d_stl']; + const cadFilter = {'terms': {'value.stream.source.contentType': cadTypes}}; + filters.push(cadFilter); + } + } + if (input.claimType === 'channel' || input.claimType === 'file') { + var query = ''; + if (input.claimType === 'channel') { + query = 'certificateType'; + } else if (input.claimType === 'file') { + query = 'streamType'; + } + const claimTypeFilter = {'match': {'value.claimType': query}}; + filters.push(claimTypeFilter); + } if (filters.length > 0) { const filterQuery = [ { diff --git a/server/routes/lighthouse.js b/server/routes/lighthouse.js index a48ce2b..0f05b09 100644 --- a/server/routes/lighthouse.js +++ b/server/routes/lighthouse.js @@ -20,6 +20,9 @@ router.get('/', LighthouseControllers.info); * - (query) size {Integer} The amount of results to return at max * - (query) from {Integer} The number to start from, good for pagination * - (query) nsfw {Boolean} If search should return nsfw content or not. + * - (query) contentType {String} Filter by MIME type. + * - (query) mediaType {String} Filter by media type, can be audio, video, image, application, text or cad. + * - (query) claimType {String} Return channels or files only, value can be 'channel' or 'file'. * responses: * 200: * description: The search API returns an array of the found matching search items. -- 2.45.2 From 854875d0d7eb8cc68f9e32c7be167d3ab1d999a8 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Thu, 8 Nov 2018 13:56:28 +0100 Subject: [PATCH 2/2] Generated docs --- docs/index.html | 271 +++++++++++++++++++++++----------------------- docs/swagger.json | 24 ++++ 2 files changed, 161 insertions(+), 134 deletions(-) diff --git a/docs/index.html b/docs/index.html index 41bf3ef..c9bc11c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -15,10 +15,10 @@ +.sc-gwVKww {} .jtxFSh{position:absolute;left:20px;height:1.8em;width:0.9em;} .jtxFSh path{fill:primary:#333333;secondary:#808080;} -

Lighthouse (0.0.1)

Download OpenAPI specification:Download

LBRY Inc: filip@lbry.io URL: https://lbry.io License: MIT

Lighthouse is a search engine for the LBRY blockchain based on elasticsearch, chainquery and Node.JS.

-

Search API

Returns all the searches matching the search query

Returns all the searches matching the search query.

-
query Parameters
s
required
string

The search text

-
channel
string

The channel to search, if none, will return all search results

-
size
integer

The amount of results to return at max

-
from
integer

The number to start from, good for pagination

-
nsfw
boolean

If search should return nsfw content or not.

-

Responses

200

The search API returns an array of the found matching search items.

-
get /search
https://lighthouse.lbry.io/search

Response samples

application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Autocomplete API

Returns an array of autocompleted strings.

Returns an array of autocompleted strings.

-
query Parameters
s
required
string

The string to be autocompleted.

-

Responses

200

The autocomplete API returns an array of the found matching autocompleted strings.

-
get /autocomplete
https://lighthouse.lbry.io/autocomplete

Response samples

application/json
Copy
Expand all Collapse all
[
  • "lbryisawesome"
]

Status API

Returns the current status of the lighthouse insta

Returns the current status of the lighthouse instance.

-

Responses

200

Returns the current status of the lighthouse instance.

-
get /status
https://lighthouse.lbry.io/status

Response samples

application/json
Copy
Expand all Collapse all
{
  • "spaceUsed": "632.3MB",
  • "claimsInIndex": 97615085,
  • "totSearches": 100000
}
+ " fill="currentColor">

Lighthouse (0.0.1)

Download OpenAPI specification:Download

LBRY Inc: filip@lbry.io URL: https://lbry.io License: MIT

Lighthouse is a search engine for the LBRY blockchain based on elasticsearch, chainquery and Node.JS.

+

Search API

Returns all the searches matching the search query

Returns all the searches matching the search query.

+
query Parameters
s
required
string

The search text

+
channel
string

The channel to search, if none, will return all search results

+
size
integer

The amount of results to return at max

+
from
integer

The number to start from, good for pagination

+
nsfw
boolean

If search should return nsfw content or not.

+
contentType
string

Filter by MIME type.

+
mediaType
string

Filter by media type, can be audio, video, image, application, text or cad.

+
claimType
string

Return channels or files only, value can be 'channel' or 'file'.

+

Responses

200

The search API returns an array of the found matching search items.

+
get /search
https://lighthouse.lbry.io/search

Response samples

application/json
Copy
Expand all Collapse all
[
  • {
    }
]

Autocomplete API

Returns an array of autocompleted strings.

Returns an array of autocompleted strings.

+
query Parameters
s
required
string

The string to be autocompleted.

+

Responses

200

The autocomplete API returns an array of the found matching autocompleted strings.

+
get /autocomplete
https://lighthouse.lbry.io/autocomplete

Response samples

application/json
Copy
Expand all Collapse all
[
  • "lbryisawesome"
]

Status API

Returns the current status of the lighthouse insta

Returns the current status of the lighthouse instance.

+

Responses

200

Returns the current status of the lighthouse instance.

+
get /status
https://lighthouse.lbry.io/status

Response samples

application/json
Copy
Expand all Collapse all
{
  • "spaceUsed": "632.3MB",
  • "claimsInIndex": 97615085,
  • "totSearches": 100000
}