Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search query possibilities #455

Open
ondratra opened this issue Sep 3, 2021 · 3 comments
Open

Improve search query possibilities #455

ondratra opened this issue Sep 3, 2021 · 3 comments
Labels
bug Something isn't working enhancement New feature or request estimate-9h 9h task med-prio qn-hydra-board

Comments

@ondratra
Copy link
Contributor

ondratra commented Sep 3, 2021

Currently, queries searching text fields have limited capabilities.

The following query finds records that have their text exactly test, but doesn't find records that contain the text as a substring e.g. mytest.

query {
  search(text: "test") {
    item {
      __typename
      ... on Channel {
        title
      }
      ... on Video {
        title
      }
    }
    rank
  }
}

Research more about current limits of search for a text. If possible, create a feature that will enable searching for both an exact word or part of a string.

@ondratra ondratra added the enhancement New feature or request label Sep 3, 2021
@ondratra ondratra self-assigned this Sep 3, 2021
@ondratra
Copy link
Contributor Author

ondratra commented Sep 14, 2021

After more testing, it seems that the search for test will find mytest, but some irregularities were experienced.

When tried on sumer-dev2 server, SQL query created for the GraphQL query described above suspiciously returned the same value for Postgres ts_rank, which is odd. Also, when changing the searched text to search(text: "test 8")... it wrongly finds some a video that has title cat2. We need to dig a little bit deeper to find the cause of these troubles.
fulltextSQL

About features/limitation:
For each such fulltext query, there are 2 files generated from a template by Hydra XXXqueryNameXXX.resolver.ts and XXXqueryNameXXX.service.ts. That gives us a lot of space if we need to change the behavior since we are creating SQL queries in .service.ts file.

In input schema, we can mark a property as fulltext searchable by @fulltext directive title: String @fulltext(query: "search"). We can have multiple fulltext queries e.g. one for searching in video and channel titles and another for searching category names.

We can use the filtering directives whereXXXentityNameXXX for fulltext as we do for regular entities e.g. search(text: "test", whereVideo: {channelId_eq: 8}) {...}. Currently, one property can be part of only one fulltext search (title: String @fulltext(query: "search") @fulltext(query: "mySecondSearch") will not work - see #457).

@ondratra
Copy link
Contributor Author

In the light of recent discoveries described in Joystream/joystream#2800 we can consider creating a brand new schema directive (e.g. @ourNewSearch similarly to what's described in #457) and start from scratch to get rid of problematic inner workings of @fulltext. This may or may not be a good approach and should be decided after further inspection of the cause of problems described in Joystream/joystream#2800.

@dmtrjsg
Copy link

dmtrjsg commented Aug 17, 2022

Needed for ordering results by relevance

Pioneer - Forum
Atlas - search for videos/ channels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request estimate-9h 9h task med-prio qn-hydra-board
Projects
None yet
Development

No branches or pull requests

2 participants