1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

fixed search syntax (#874)

* fixed search syntax

* fixed query structure

* fix search structure

* fix fetch algos

* fix published query

* fix published

* fix
This commit is contained in:
mihaisc 2021-09-24 14:32:14 +03:00 committed by GitHub
parent bf03a62f49
commit aee246cf7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 20 deletions

View File

@ -123,14 +123,12 @@ import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/Metadata
import { queryMetadata } from '../../utils/aquarius'
const queryLatest = {
page: 1,
offset: 9,
query: {
// https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
query_string: { query: `-isInPurgatory:true` }
},
sort: { created: -1 }
sort: { created: 'desc' }
}
function Component() {

View File

@ -153,7 +153,6 @@ export default function Compute({
const algorithmQuery =
trustedAlgorithmList.length > 0 ? `(${algoQuerry}) AND` : ``
const query = {
offset: 500,
query: {
query_string: {
query: `${algorithmQuery} service.attributes.main.type:algorithm AND chainId:${chainId} -isInPurgatory:true`

View File

@ -38,13 +38,12 @@ export default function FormEditComputeDataset({
): Promise<AssetSelectionAsset[]> {
const source = axios.CancelToken.source()
const query = {
offset: 500,
query: {
query_string: {
query: `service.attributes.main.type:algorithm AND chainId:${ddo.chainId} -isInPurgatory:true`
}
},
sort: { created: -1 }
sort: { created: 'desc' }
}
const querryResult = await queryMetadata(query, source.token)
const datasetComputeService = ddo.findServiceByType('compute')

View File

@ -33,7 +33,7 @@ export default function PublishedList({
accountId,
chainIds,
cancelTokenSource.token,
page,
page - 1,
service
)
setQueryResult(result)

View File

@ -23,11 +23,23 @@ export const MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS = 476
function getQueryForAlgorithmDatasets(algorithmDid: string, chainId?: number) {
return {
query: {
query_string: {
query: `service.attributes.main.privacy.publisherTrustedAlgorithms.did:${algorithmDid} AND chainId:${chainId}`
bool: {
must: [
{
match: {
'service.attributes.main.privacy.publisherTrustedAlgorithms.did':
algorithmDid
}
},
{
query_string: {
query: `chainId:${chainId}`
}
}
]
}
},
sort: { created: -1 }
sort: { created: 'desc' }
}
}
@ -77,6 +89,7 @@ export async function queryMetadata(
{ cancelToken }
)
if (!response || response.status !== 200 || !response.data) return
return transformQueryResult(response.data, query.from, query.size)
} catch (error) {
if (axios.isCancel(error)) {
@ -220,12 +233,11 @@ export async function getPublishedAssets(
): Promise<any> {
if (!accountId) return
page = page || 1
type = type || 'dataset OR algorithm'
const queryPublishedAssets = {
page,
offset: 9,
from: (Number(page) || 0) * (Number(9) || 21),
size: Number(9) || 21,
query: {
query_string: {
query: `(publicKey.owner:${accountId}) AND (service.attributes.main.type:${type}) AND (${transformChainIdsListToQuery(
@ -233,9 +245,8 @@ export async function getPublishedAssets(
)})`
}
},
sort: { created: -1 }
sort: { created: 'desc' }
}
try {
const result = await queryMetadata(queryPublishedAssets, cancelToken)
return result
@ -266,8 +277,6 @@ export async function getAssetsFromDidList(
if (!searchDids) return
const query = {
page: 1,
offset: 1000,
query: {
query_string: {
query: `(${searchDids}) AND (${transformChainIdsListToQuery(
@ -277,7 +286,7 @@ export async function getAssetsFromDidList(
default_operator: 'OR'
}
},
sort: { created: -1 }
sort: { created: 'desc' }
}
const queryResult = await queryMetadata(query, cancelToken)

View File

@ -72,8 +72,6 @@ async function getAssetMetadata(
chainIds: number[]
): Promise<DDO[]> {
const queryDid = {
page: 1,
offset: 100,
query: {
query_string: {
query: `(${queryDtList}) AND (${transformChainIdsListToQuery(