From da02023c7a8b0a9fb8ffe3f0f1b5ae981092fdae Mon Sep 17 00:00:00 2001 From: filipnyquist Date: Tue, 5 Feb 2019 11:10:25 +0100 Subject: [PATCH 1/4] Added two simple examples to README. Added two small examples for search and autocomplete so people can try it out without digging into the API doc. --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a72821..5fc0133 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,15 @@ The official lighthouse instance is live at https://lighthouse.lbry.io 1. Elasticsearch as a backend db server. 2. LBRYimport, an importer that imports the claims into the Elasticsearch database. 3. Lighthouse API server, which serves the API and does all calculations about what to send to the end user. -### API Documentation - +### API Documentation / Usage example +To make a simple search by string: +``` +https://lighthouse.lbry.io/search?s=stringtosearch +``` +To get autocomplete suggestions: +``` +https://lighthouse.lbry.io/autocomplete?s=stringtocomp +``` [The full API documentation](https://lbryio.github.io/lighthouse/) ## Installation -- 2.45.2 From c870f05faa6ca4278c96930bcc661088cd667c0a Mon Sep 17 00:00:00 2001 From: filipnyquist Date: Tue, 5 Feb 2019 11:12:37 +0100 Subject: [PATCH 2/4] Removed old information from README We are not using the python decoder anymore as we are using chainquery nowadays. --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 5fc0133..b153060 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ https://lighthouse.lbry.io/autocomplete?s=stringtocomp ### Prerequisites * [Node v8](https://nodejs.org/en/download/) * [Yarn](https://yarnpkg.com/en/docs/install) -* [Python 2.7](https://www.python.org/downloads/) * [Elasticsearch](https://www.elastic.co/downloads/elasticsearch) @@ -34,11 +33,6 @@ https://lighthouse.lbry.io/autocomplete?s=stringtocomp ``` git clone https://github.com/lbryio/lighthouse ``` ->Grab the latest release of lbrycrd here: - -[Download lbrycrd](https://github.com/lbryio/lbrycrd/releases) ->Create a lbrycrd config file at ~/.lbrycrd/lbrycrd.conf which contains rpcuser,rpcpassword and rpcport. Then run lbrycrd in the background with that config file. - >Make sure elasticsearch is running and run (from the lighthouse dir): ``` ./gendb.sh @@ -47,10 +41,6 @@ git clone https://github.com/lbryio/lighthouse ``` yarn install --production=false ``` ->Start an instance of the decoder: -``` -cd decoder && pip install -r requirements.txt && python decoder.py -``` >Build and run Lighthouse: ``` yarn run prod -- 2.45.2 From 70415626c5ead32598128638f010b51a0542ddc9 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Mon, 22 Oct 2018 09:59:12 +0200 Subject: [PATCH 3/4] Added content type filter Added claim type filter Improved filtering and return no results when wrong input List of types as input for mediaType and contentType --- server/controllers/lighthouse.js | 39 ++++++++++++++++++++++++++++++-- server/routes/lighthouse.js | 3 +++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 6eb8578..27466f1 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -255,14 +255,49 @@ 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 contentTypes = input.contentType.split(','); + const contentFilter = {'terms': {'value.stream.source.contentType.keyword': contentTypes}}; + filters.push(contentFilter); + } + if (input.mediaType !== undefined) { + const mediaTypes = input.mediaType.split(','); + const possibleTypes = ['audio', 'video', 'text', 'application', 'image']; + const shouldQueries = []; + for (var i = 0; i < mediaTypes.length; i++) { + if (possibleTypes.includes(mediaTypes[i])) { + const mediaFilter = {'prefix': {'value.stream.source.contentType.keyword': mediaTypes[i] + '/'}}; + shouldQueries.push(mediaFilter); + } else if (mediaTypes[i] === 'cad') { + const cadTypes = ['SKP', 'simplify3d_stl']; + const cadFilter = {'terms': {'value.stream.source.contentType.keyword': cadTypes}}; + shouldQueries.push(cadFilter); + } + } + if (shouldQueries.length === 0) { + const noneFilter = {'match_none': {}}; + filters.push(noneFilter); + } else { + const mediaTypeFilter = {'bool': {'should': shouldQueries}}; + filters.push(mediaTypeFilter); + } + } + 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 ed948fda2e6b543c676dedeb43c3c430bc6b1ca7 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Thu, 8 Nov 2018 13:56:28 +0100 Subject: [PATCH 4/4] 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
}