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

fix tag search (#1651)

This commit is contained in:
mihaisc 2022-08-12 02:38:13 -07:00 committed by GitHub
parent dc4add5c70
commit 27517faea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 77 deletions

View File

@ -15,9 +15,7 @@ const Tag = ({ tag, noLinks }: { tag: string; noLinks?: boolean }) => {
return noLinks ? (
<span className={styles.tag}>{tag}</span>
) : (
<Link
href={`/search?tags=${urlEncodedTag}&sort=metadata.created&sortOrder=desc`}
>
<Link href={`/search?tags=${urlEncodedTag}&sort=_score&sortOrder=desc`}>
<a className={styles.tag} title={tag}>
{tag}
</a>

View File

@ -35,7 +35,6 @@ export function getSearchQuery(
text?: string,
owner?: string,
tags?: string,
categories?: string,
page?: string,
offset?: string,
sort?: string,
@ -45,17 +44,12 @@ export function getSearchQuery(
): SearchQuery {
text = escapeESReservedChars(text)
const emptySearchTerm = text === undefined || text === ''
let searchTerm = owner
? `(nft.owner:${owner})`
: tags
? // eslint-disable-next-line no-useless-escape
`(metadata.tags:\"${tags}\")`
: // : categories
// ? // eslint-disable-next-line no-useless-escape
// `(service.attributes.additionalInformation.categories:\"${categories}\")`
text || ''
const filters: FilterTerm[] = []
let searchTerm = text || ''
let nestedQuery
if (tags) {
filters.push(getFilterTerm('metadata.tags.keyword', tags))
} else {
searchTerm = searchTerm.trim()
const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim()
const noSpaceSearchTerm = searchTerm.split(' ').join('').trim()
@ -78,7 +72,7 @@ export function getSearchQuery(
'metadata.tags'
]
const nestedQuery = {
nestedQuery = {
must: [
{
bool: {
@ -120,8 +114,7 @@ export function getSearchQuery(
}
]
}
const filters: FilterTerm[] = []
}
accessType !== undefined &&
filters.push(getFilterTerm('services.type', accessType))
serviceType !== undefined &&
@ -162,7 +155,6 @@ export async function getResults(
text,
owner,
tags,
categories,
page,
offset,
sort,
@ -176,7 +168,6 @@ export async function getResults(
text,
owner,
tags,
categories,
page,
offset,
sort,