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:
parent
bf03a62f49
commit
aee246cf7a
@ -123,14 +123,12 @@ import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatacache/Metadata
|
|||||||
import { queryMetadata } from '../../utils/aquarius'
|
import { queryMetadata } from '../../utils/aquarius'
|
||||||
|
|
||||||
const queryLatest = {
|
const queryLatest = {
|
||||||
page: 1,
|
|
||||||
offset: 9,
|
|
||||||
query: {
|
query: {
|
||||||
// https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
|
// https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
|
||||||
|
|
||||||
query_string: { query: `-isInPurgatory:true` }
|
query_string: { query: `-isInPurgatory:true` }
|
||||||
},
|
},
|
||||||
sort: { created: -1 }
|
sort: { created: 'desc' }
|
||||||
}
|
}
|
||||||
|
|
||||||
function Component() {
|
function Component() {
|
||||||
|
@ -153,7 +153,6 @@ export default function Compute({
|
|||||||
const algorithmQuery =
|
const algorithmQuery =
|
||||||
trustedAlgorithmList.length > 0 ? `(${algoQuerry}) AND` : ``
|
trustedAlgorithmList.length > 0 ? `(${algoQuerry}) AND` : ``
|
||||||
const query = {
|
const query = {
|
||||||
offset: 500,
|
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
query_string: {
|
||||||
query: `${algorithmQuery} service.attributes.main.type:algorithm AND chainId:${chainId} -isInPurgatory:true`
|
query: `${algorithmQuery} service.attributes.main.type:algorithm AND chainId:${chainId} -isInPurgatory:true`
|
||||||
|
@ -38,13 +38,12 @@ export default function FormEditComputeDataset({
|
|||||||
): Promise<AssetSelectionAsset[]> {
|
): Promise<AssetSelectionAsset[]> {
|
||||||
const source = axios.CancelToken.source()
|
const source = axios.CancelToken.source()
|
||||||
const query = {
|
const query = {
|
||||||
offset: 500,
|
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
query_string: {
|
||||||
query: `service.attributes.main.type:algorithm AND chainId:${ddo.chainId} -isInPurgatory:true`
|
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 querryResult = await queryMetadata(query, source.token)
|
||||||
const datasetComputeService = ddo.findServiceByType('compute')
|
const datasetComputeService = ddo.findServiceByType('compute')
|
||||||
|
@ -33,7 +33,7 @@ export default function PublishedList({
|
|||||||
accountId,
|
accountId,
|
||||||
chainIds,
|
chainIds,
|
||||||
cancelTokenSource.token,
|
cancelTokenSource.token,
|
||||||
page,
|
page - 1,
|
||||||
service
|
service
|
||||||
)
|
)
|
||||||
setQueryResult(result)
|
setQueryResult(result)
|
||||||
|
@ -23,11 +23,23 @@ export const MAXIMUM_NUMBER_OF_PAGES_WITH_RESULTS = 476
|
|||||||
function getQueryForAlgorithmDatasets(algorithmDid: string, chainId?: number) {
|
function getQueryForAlgorithmDatasets(algorithmDid: string, chainId?: number) {
|
||||||
return {
|
return {
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
bool: {
|
||||||
query: `service.attributes.main.privacy.publisherTrustedAlgorithms.did:${algorithmDid} AND chainId:${chainId}`
|
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 }
|
{ cancelToken }
|
||||||
)
|
)
|
||||||
if (!response || response.status !== 200 || !response.data) return
|
if (!response || response.status !== 200 || !response.data) return
|
||||||
|
|
||||||
return transformQueryResult(response.data, query.from, query.size)
|
return transformQueryResult(response.data, query.from, query.size)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (axios.isCancel(error)) {
|
if (axios.isCancel(error)) {
|
||||||
@ -220,12 +233,11 @@ export async function getPublishedAssets(
|
|||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
if (!accountId) return
|
if (!accountId) return
|
||||||
|
|
||||||
page = page || 1
|
|
||||||
type = type || 'dataset OR algorithm'
|
type = type || 'dataset OR algorithm'
|
||||||
|
|
||||||
const queryPublishedAssets = {
|
const queryPublishedAssets = {
|
||||||
page,
|
from: (Number(page) || 0) * (Number(9) || 21),
|
||||||
offset: 9,
|
size: Number(9) || 21,
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
query_string: {
|
||||||
query: `(publicKey.owner:${accountId}) AND (service.attributes.main.type:${type}) AND (${transformChainIdsListToQuery(
|
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 {
|
try {
|
||||||
const result = await queryMetadata(queryPublishedAssets, cancelToken)
|
const result = await queryMetadata(queryPublishedAssets, cancelToken)
|
||||||
return result
|
return result
|
||||||
@ -266,8 +277,6 @@ export async function getAssetsFromDidList(
|
|||||||
if (!searchDids) return
|
if (!searchDids) return
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
page: 1,
|
|
||||||
offset: 1000,
|
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
query_string: {
|
||||||
query: `(${searchDids}) AND (${transformChainIdsListToQuery(
|
query: `(${searchDids}) AND (${transformChainIdsListToQuery(
|
||||||
@ -277,7 +286,7 @@ export async function getAssetsFromDidList(
|
|||||||
default_operator: 'OR'
|
default_operator: 'OR'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
sort: { created: -1 }
|
sort: { created: 'desc' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const queryResult = await queryMetadata(query, cancelToken)
|
const queryResult = await queryMetadata(query, cancelToken)
|
||||||
|
@ -72,8 +72,6 @@ async function getAssetMetadata(
|
|||||||
chainIds: number[]
|
chainIds: number[]
|
||||||
): Promise<DDO[]> {
|
): Promise<DDO[]> {
|
||||||
const queryDid = {
|
const queryDid = {
|
||||||
page: 1,
|
|
||||||
offset: 100,
|
|
||||||
query: {
|
query: {
|
||||||
query_string: {
|
query_string: {
|
||||||
query: `(${queryDtList}) AND (${transformChainIdsListToQuery(
|
query: `(${queryDtList}) AND (${transformChainIdsListToQuery(
|
||||||
|
Loading…
Reference in New Issue
Block a user