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

how we do search with join #251

Open
REDAL opened this issue Jan 7, 2023 · 6 comments
Open

how we do search with join #251

REDAL opened this issue Jan 7, 2023 · 6 comments

Comments

@REDAL
Copy link

REDAL commented Jan 7, 2023

how we do search in data with join, where the fields we search are in both tables (stores )

@REDAL REDAL changed the title query not retuning data how we do search with join Jan 9, 2023
@REDAL
Copy link
Author

REDAL commented Jan 9, 2023

@rakibtg any thaugths

@rakibtg
Copy link
Member

rakibtg commented Jan 9, 2023

@REDAL i think the best solution would be to run that logic in the application layer

@REDAL
Copy link
Author

REDAL commented Jan 9, 2023

@REDAL i think the best solution would be to run that logic in the application layer

can you give me an example ? please

@REDAL
Copy link
Author

REDAL commented Jan 16, 2023

@rakibtg ?! any help here Hasan

@Timu57
Copy link
Member

Timu57 commented May 17, 2023

Hi @REDAL sorry for the late response.
You can see the order of execution here: https://sleekdb.github.io/#/execution-order
As you can see search comes after join.
That means you can do a join and search afterwards. For example:

$userStore = new Store("users", $dataDir);
$commentStore = new Store("comments", $dataDir);

$searchQuery = "SleekDB is the best database solution";

$users = $usersStore
  ->createQueryBuilder()
  ->join(function($user) use ($commentStore){
    // returns result
    return $commentStore->findBy([ "userId", "=", $user["_id"] ]);
  }, "comments")
  ->search(['comments.0.title', 'comments.0.content'], $searchQuery)
  ->orderBy(["searchScore" => "DESC"])
  ->getQuery()
  ->fetch();

The example above will first join users and comments. Afterwards it will search the first joined comment of every user.
Unfortunately we currently haven't implemented wildcards like comments.*.title. That's the reason why searching after a join probably will not do what you need.

@REDAL
Copy link
Author

REDAL commented May 17, 2023 via email

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

No branches or pull requests

3 participants