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:
parent
dc4add5c70
commit
27517faea2
@ -15,9 +15,7 @@ const Tag = ({ tag, noLinks }: { tag: string; noLinks?: boolean }) => {
|
|||||||
return noLinks ? (
|
return noLinks ? (
|
||||||
<span className={styles.tag}>{tag}</span>
|
<span className={styles.tag}>{tag}</span>
|
||||||
) : (
|
) : (
|
||||||
<Link
|
<Link href={`/search?tags=${urlEncodedTag}&sort=_score&sortOrder=desc`}>
|
||||||
href={`/search?tags=${urlEncodedTag}&sort=metadata.created&sortOrder=desc`}
|
|
||||||
>
|
|
||||||
<a className={styles.tag} title={tag}>
|
<a className={styles.tag} title={tag}>
|
||||||
{tag}
|
{tag}
|
||||||
</a>
|
</a>
|
||||||
|
@ -35,7 +35,6 @@ export function getSearchQuery(
|
|||||||
text?: string,
|
text?: string,
|
||||||
owner?: string,
|
owner?: string,
|
||||||
tags?: string,
|
tags?: string,
|
||||||
categories?: string,
|
|
||||||
page?: string,
|
page?: string,
|
||||||
offset?: string,
|
offset?: string,
|
||||||
sort?: string,
|
sort?: string,
|
||||||
@ -45,17 +44,12 @@ export function getSearchQuery(
|
|||||||
): SearchQuery {
|
): SearchQuery {
|
||||||
text = escapeESReservedChars(text)
|
text = escapeESReservedChars(text)
|
||||||
const emptySearchTerm = text === undefined || text === ''
|
const emptySearchTerm = text === undefined || text === ''
|
||||||
|
const filters: FilterTerm[] = []
|
||||||
let searchTerm = owner
|
let searchTerm = text || ''
|
||||||
? `(nft.owner:${owner})`
|
let nestedQuery
|
||||||
: tags
|
if (tags) {
|
||||||
? // eslint-disable-next-line no-useless-escape
|
filters.push(getFilterTerm('metadata.tags.keyword', tags))
|
||||||
`(metadata.tags:\"${tags}\")`
|
} else {
|
||||||
: // : categories
|
|
||||||
// ? // eslint-disable-next-line no-useless-escape
|
|
||||||
// `(service.attributes.additionalInformation.categories:\"${categories}\")`
|
|
||||||
text || ''
|
|
||||||
|
|
||||||
searchTerm = searchTerm.trim()
|
searchTerm = searchTerm.trim()
|
||||||
const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim()
|
const modifiedSearchTerm = searchTerm.split(' ').join(' OR ').trim()
|
||||||
const noSpaceSearchTerm = searchTerm.split(' ').join('').trim()
|
const noSpaceSearchTerm = searchTerm.split(' ').join('').trim()
|
||||||
@ -78,7 +72,7 @@ export function getSearchQuery(
|
|||||||
'metadata.tags'
|
'metadata.tags'
|
||||||
]
|
]
|
||||||
|
|
||||||
const nestedQuery = {
|
nestedQuery = {
|
||||||
must: [
|
must: [
|
||||||
{
|
{
|
||||||
bool: {
|
bool: {
|
||||||
@ -120,8 +114,7 @@ export function getSearchQuery(
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const filters: FilterTerm[] = []
|
|
||||||
accessType !== undefined &&
|
accessType !== undefined &&
|
||||||
filters.push(getFilterTerm('services.type', accessType))
|
filters.push(getFilterTerm('services.type', accessType))
|
||||||
serviceType !== undefined &&
|
serviceType !== undefined &&
|
||||||
@ -162,7 +155,6 @@ export async function getResults(
|
|||||||
text,
|
text,
|
||||||
owner,
|
owner,
|
||||||
tags,
|
tags,
|
||||||
categories,
|
|
||||||
page,
|
page,
|
||||||
offset,
|
offset,
|
||||||
sort,
|
sort,
|
||||||
@ -176,7 +168,6 @@ export async function getResults(
|
|||||||
text,
|
text,
|
||||||
owner,
|
owner,
|
||||||
tags,
|
tags,
|
||||||
categories,
|
|
||||||
page,
|
page,
|
||||||
offset,
|
offset,
|
||||||
sort,
|
sort,
|
||||||
|
Loading…
Reference in New Issue
Block a user