Skip to content

Search issues fix#641

Merged
claudiaHash merged 26 commits into
mainfrom
fix/619-search-issues
Jun 15, 2021
Merged

Search issues fix#641
claudiaHash merged 26 commits into
mainfrom
fix/619-search-issues

Conversation

@claudiaHash

@claudiaHash claudiaHash commented Jun 3, 2021

Copy link
Copy Markdown
Contributor

Fixes #619 .

Changes proposed in this PR:

  • search by datatoken address, owner address, asset id added to existent elasticsearch query

@vercel

vercel Bot commented Jun 3, 2021

Copy link
Copy Markdown

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/oceanprotocol/market/6AZJVnxziczyxZEjD2cb8xLScgk9
✅ Preview: https://market-git-fix-619-search-issues-oceanprotocol.vercel.app

@mihaisc mihaisc self-requested a review June 3, 2021 11:30
mihaisc
mihaisc previously approved these changes Jun 3, 2021

@mihaisc mihaisc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, not sure if you want to add more since it's still in draft.
Fixes just a small issue from #619.

@claudiaHash

Copy link
Copy Markdown
Contributor Author

Looks good, not sure if you want to add more since it's still in draft.
Fixes just a small issue from #619.

There are still some issues unresolved yet that I'm working on.

@claudiaHash claudiaHash changed the title Fix/619 search issues Search issues fix Jun 7, 2021
should: [
{
query_string: {
query: `${searchTerm}`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchTerm differs in query_string you need to manually add OR between the words . in match_prase it's exactly the string the user inputs.

'service.attributes.additionalInformation.description',
'service.attributes.additionalInformation.tags'
],
default_operator: 'AND',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line, it shouldn't be AND

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added 'AND' as default op because using OR would give a match for every word in search string. For "worldlist used by" I got matches for assets that only contain "used" in their description/ title/ etc

@mihaisc mihaisc Jun 7, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please use the searchTerm formated as described above with 'OR' between each word. "worldlist used by" would become "worldlist OR used OR by", just in query_string, not in match_phrase. Because you didn't add OR the query wasn't working properly that's why the results were not ok

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't used 2 different search terms on query_string and match_phrase there's where the problem came from. Please ignore the comments.

`(service.attributes.additionalInformation.categories:\"${categories}\")`
: text || ''

if (searchTerm.startsWith('did:op:')) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it because searching by id that included "did:op:" in the beginning gave no result. Since the address that follows differentiates the assets, I thought that could be a solution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should work without removing did:op. Comment it for now. It work ok in my tests without removing did:op

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searching for a2B8b3aC4207CFCCbDe4Ac7fa40214fd00A2BA71 is not working anyway

searchTerm = searchTerm.substring(7)
}
// HACK: resolves the case sensitivity related to dataTokenInfo.symbol
searchTerm = '*' + searchTerm.toUpperCase() + '*'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stop adding * at the start and end of the string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added them for the cases user doesn't type all the search word. When searching by token symbol I found the following problem:
Screenshot from 2021-06-07 17-22-43
Screenshot from 2021-06-07 17-22-55

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it creates problems in other places. Searching for datatoken symbol will be fixed in oceanprotocol/aquarius#492

@claudiaHash claudiaHash Jun 7, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ok then I'll remove it. That was the only issue * resolved.

@mihaisc

mihaisc commented Jun 7, 2021

Copy link
Copy Markdown
Contributor

We'll tweak the query after these changes are implemented.

@claudiaHash

Copy link
Copy Markdown
Contributor Author

I added that did:op: hack because I found that if the query_string and match_phrase search terms don't match case wise (only in that particular case) we get a server error:
Screenshot from 2021-06-07 19-09-08

It worked after that:
Screenshot from 2021-06-07 19-23-07

@mihaisc

mihaisc commented Jun 8, 2021

Copy link
Copy Markdown
Contributor

Ok, i'll play with it a bit and see how relevant are the result and if i can improve the query even more.

@claudiaHash

Copy link
Copy Markdown
Contributor Author

Not sure if a - separated search input should give results for the whole string or if it's ok if terms are separated. Eg. mayors-office gives results that match: "office", "mayors-office"

@mihaisc

mihaisc commented Jun 8, 2021

Copy link
Copy Markdown
Contributor

it's ok, the secret is that we order them properly. We need to ad the sort criteria, after score. Currently they are sorted by created or if no sort filter is specified aquarius sorts them by id (it's not ok, an issue was created). The scope is to create multiple queries and order the matches. For example in the current queries match_phrase is the most strict and will be first in the results.

mihaisc added 2 commits June 9, 2021 11:25
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
@mihaisc

mihaisc commented Jun 9, 2021

Copy link
Copy Markdown
Contributor

I removed the SearchQuery return type because we can't use it and i'm not sure why even bother. The structure of the es query is too complex and i see no value in trying to map in typescript

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
@mihaisc

mihaisc commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

It would be good to include results where there is a partial match. For example, if you search "data union" you'll find that "dataunion.app" doesn't appear in the results

While this seems to be possible (check links below) it is far too complex to handle in this pr. It is nice to have indeed and I will create a new issue for it

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-word-delimiter-tokenfilter.html
https://www.javacodegeeks.com/2018/03/elasticsearch-ignore-special-characters-query-pattern-replace-filter-custom-analyzer.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-shingle-tokenfilter.html

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
@mihaisc mihaisc marked this pull request as ready for review June 14, 2021 14:59
@mihaisc mihaisc requested a review from kremalicious as a code owner June 14, 2021 14:59
@mihaisc

mihaisc commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

There already a lot of improvements here. I have commented Relevance sort until it's fixed. There are some other issues in aqua but i don't want to block this pr based on them. It's already good enough. Created 2 other issues based on things found here.

One last test from someone else please.

@kremalicious

kremalicious commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

using this new search strategy in the background is already super valuable and seems to work well after some quick tests. One important, because very prominent, search which I found to be not working at all is the owner search, so the prominent publisher link on asset details page. When clicking that it looks to me as there is no search filtering happening at all, only lists recent items, e.g. https://market-git-fix-619-search-issues-oceanprotocol.vercel.app/search/?owner=0x655eFe6Eb2021b8CEfE22794d90293aeC37bb325&sort=created&sortOrder=desc

@mihaisc

mihaisc commented Jun 14, 2021

Copy link
Copy Markdown
Contributor

Ok, thanks on that. I remember now, i wanted to remove those but didn't finish. This way there is a bug if you click on your link and then search for something else (delete address and type something else ) nothing will happen.

@mihaisc mihaisc dismissed their stale review June 14, 2021 21:04

old, bugs found

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
@qlty-cloud-legacy

Copy link
Copy Markdown

Code Climate has analyzed commit 44bb3aa and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

View more on Code Climate.

@mihaisc

mihaisc commented Jun 15, 2021

Copy link
Copy Markdown
Contributor

Ok, it should be working now ok.

@claudiaHash

claudiaHash commented Jun 15, 2021

Copy link
Copy Markdown
Contributor Author

Ok, it should be working now ok.

The search after link clicking works perfectly. Since what I tested, the rest of the search works as it did before the last push. I think we could finally merge it.

@jamiehewitt15

Copy link
Copy Markdown
Contributor

It's a big improvement on before, all of the issues I mentioned above are fixed now.

@claudiaHash claudiaHash merged commit eb8c6af into main Jun 15, 2021
@claudiaHash claudiaHash deleted the fix/619-search-issues branch June 15, 2021 13:46
@jamiehewitt15 jamiehewitt15 mentioned this pull request Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search issues

4 participants