Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Geosearch for zero radius #713

Closed
wants to merge 1 commit into from
Closed

Conversation

amab8901
Copy link
Contributor

@amab8901 amab8901 commented Nov 30, 2022

Pull Request

Related issue

Fixes #3167 (meilisearch/meilisearch#3167)

What does this PR do?

  • allows Geosearch with zero radius to return the specified location when the coordinates match perfectly (instead of returning nothing). See link for more details.

PR checklist

Please check if your PR fulfills the following requirements:

  • [ X ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • [ X ] Have you read the contributing guidelines?
  • [ X ] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Copy link
Member

@irevoire irevoire left a comment

Choose a reason for hiding this comment

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

Hey @amab8901, thanks a lot for your investigation!
Sorry to nitpick with the EPSILON thingy; I don't want to risk anything and epsilon should be small enough not to cause any issues by matching too many documents.

milli/src/search/facet/filter.rs Outdated Show resolved Hide resolved
milli/src/search/facet/filter.rs Outdated Show resolved Hide resolved
@amab8901
Copy link
Contributor Author

amab8901 commented Dec 1, 2022

thanks for your feedback, I applied it. Honestly, I wasn't even sure what I was doing. I just took pieces of code here and there that looked similar to what I was trying to do, and I combined them in places that seem reasonable, and it worked for the most part (except the things you mentioned in feedback)

@irevoire irevoire added no breaking The related changes are not breaking (DB nor API) bug Something isn't working labels Dec 1, 2022
irevoire
irevoire previously approved these changes Dec 1, 2022
Copy link
Member

@irevoire irevoire left a comment

Choose a reason for hiding this comment

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

I just took pieces of code here and there that looked similar to what I was trying to do, and I combined them in places that seem reasonable, and it worked for the most part

Don't worry; that's how it goes when you start on a new codebase, you're doing great! 🌟

It seems like rustfmt is angry. Could you run it and push a new commit? cargo fmt

Then we're good to merge!

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 1, 2022

ok now I did cargo fmt. I received 4 errors when running the command though:

Error writing files: failed to resolve mod `datasets_paths`: [...]/src/milli/benchmarks/benches/datasets_paths.rs does not exist

@irevoire
Copy link
Member

irevoire commented Dec 1, 2022

Ah yes, sorry that's definitely an issue on our side, and our CONTRIBUTING.md is completely outdated 😩
Can you run a touch milli/benchmarks/benches/datasets_paths.rs before running your cargo fmt? It should fix your issue!
It's something we need to run our benchmarks, but maybe we could make it easier to use. I'll check next week 👍

Also, it look like you rebased on the wrong branch; you're now trying to merge way more commits than before 🤔

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 2, 2022

I fixed this one:

Can you run a touch milli/benchmarks/benches/datasets_paths.rs before running your cargo fmt

Only one of those commits are mine. The other ones come from other people and were introduced via git pull. What should I do?

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

Hey @amab8901, sorry I was on weekend, but I'm back now!

Only one of those commits are mine. The other ones come from other people and were introduced via git pull. What should I do?

I don't really know what happened, but the easiest thing you can do is probably to follow these steps:

git fetch origin # now origin/main` is up to date
git rebase -i origin/main
# that should open a window with a bunch of commits that are going to be rebased; you delete everything except your commits

git push --force # you need to force push because you're rewriting the git history

and then we should be good to go 😁

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

how about now? I think I'm starting to become proficient with squashing.

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

I don't know what you've done, but now I can't see anything 😢
That's how I see your PR from my side; all your changes disappeared
image

Ok, so now, the less-worse option you can do is to run:

git reset --hard origin/main # come back to the latest state of meilisearch
git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd # apply back your changes

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

ok no problem, I'll just redo it and open a new PR.

@amab8901 amab8901 closed this Dec 5, 2022
@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

But why?
Cherry-picking the commit didn't work?

Doing another PR won't change anything I think

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

But why? Cherry-picking the commit didn't work?

Doing another PR won't change anything I think

idk, I think I messed something up in the git. I ran the commands you proposed but it didn't get fixed

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

Whatever you do, it looks like you lost the changes associated with your original PR, so please do not delete your milli directory. The changes are still there somewhere, and we can get them.

Don't worry. We're going to debug this together.

First, can you show me the result of;

git remote show

# and then run; it will print the URL contained in all your remote
git remote show | xargs git remote show

Maybe you don't have the original meilisearch as your origin, and thus my previous commands did not work.

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

$ git remote show
origin

$ git remote show | xargs git remote show
* remote origin
  Fetch URL: https://github.com/amab8901/milli
  Push  URL: https://github.com/amab8901/milli
  HEAD branch: main
  Remote branches:
    3167-geosearch-zero tracked
    main                tracked
  Local branches configured for 'git pull':
    3167-geosearch-zero merges with remote 3167-geosearch-zero
    main                merges with remote main
  Local refs configured for 'git push':
    3167-geosearch-zero pushes to 3167-geosearch-zero (up to date)
    main                pushes to main                (up to date)

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

Ok, so now I know why it failed!
With this setup, my other commands were completely wrong 🙈

What we're going to do is create a second remote, so it's easier to refer to the commits coming from meilisearch.
Let's call it upstream for simplicity:

git remote add upstream https://github.com/meilisearch/milli.git # EDITED

With this command, you now have the remote origin that represents your fork of meilisearch. And the remote upstream that represents the meilisearch repository.

The next command is:

git fetch upstream

That's going to pull all the latest changes that happened on meilisearch.
Now we're going to put your branch in the latest state;

git reset --hard upstream/main

And finally, we apply your commit to this branch and push:

git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd
git push --force

That should put you back on track! 🚂
Let me know if you encounter any issues while doing that!

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

I find it interesting that I got this:

$ git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd
CONFLICT (modify/delete): milli/src/search/facet/filter.rs deleted in HEAD and modified in 55198a05 (Geosearch for zero radius).  Version 55198a05 (Geosearch for zero radius) of milli/src/search/facet/filter.rs left in tree.
error: could not apply 55198a05... Geosearch for zero radius
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

Otherwise, I made it to the end. I don't know, does it work now? I'm not really sure why the remote upstream was meilisearch rather than milli though 🤔

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

Oh gosh, yes sorry it was supposed to be milli 🤦

You can just run these commands to come back to the same state but with milli;

git cherry-pick --abort
git remote remove upstream
git remote add upstream https://github.com/meilisearch/milli.git
git fetch upstream
git reset --hard upstream/main
git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd
git push --force

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

some highlights:

$ git remote add upstream https://github.com/meilisearch/milli.git
error: remote upstream already exists.

$ git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd
CONFLICT (modify/delete): milli/src/search/facet/filter.rs deleted in HEAD and modified in 55198a05 (Geosearch for zero radius).  Version 55198a05 (Geosearch for zero radius) of milli/src/search/facet/filter.rs left in tree.
error: could not apply 55198a05... Geosearch for zero radius
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

$ git push --force
info: please complete authentication in your browser...
fatal: Failed to encrypt file '/home/amab/.password-store/git/https/github.com/amab8901.gpg' with gpg. exit=2, out=, err=gpg: rsa3072: skipped: No public key
gpg: [stdin]: encryption failed: No public key

Everything up-to-date


@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

I think you forgot a bunch of commands here 🤔
You were supposed to abort the cherry-pick + remove the remote.

Here is the list of commands you should run again

git cherry-pick --abort
git remote remove upstream
git remote add upstream https://github.com/meilisearch/milli.git
git fetch upstream
git reset --hard upstream/main
git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd
git push --force

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

I think you forgot a bunch of commands here thinking You were supposed to abort the cherry-pick + remove the remote.

Here is the list of commands you should run again

git cherry-pick --abort
git remote remove upstream
git remote add upstream https://github.com/meilisearch/milli.git
git fetch upstream
git reset --hard upstream/main
git cherry-pick 55198a058845a468651a5d17f59da1bfc648dfcd
git push --force

I ran all the commands. I shared only some interesting highlights rather than all of them. I particularly didn't share what happened if it's like empty output or something really simple and non-informative in output

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

What was the output of;

git remote remove upstream

Because it looks like this one didn't work 😬
I did a few tests on my side and I don't see where it failed

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

oh, I had a typo there on git remote remove upstream. I tried again without typo and now everything worked fine without errors.

This one git remote remove upstream didn't produce any outputs this time.

Here's now the final output:

$ git push --force
info: please complete authentication in your browser...
fatal: Failed to encrypt file '/home/amab/.password-store/git/https/github.com/amab8901.gpg' with gpg. exit=2, out=, err=gpg: rsa3072: skipped: No public key
gpg: [stdin]: encryption failed: No public key

Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1020 bytes | 1020.00 KiB/s, done.
Total 7 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To https://github.com/amab8901/milli
 + 9b23885e...456da5de 3167-geosearch-zero -> 3167-geosearch-zero (forced update)

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

Nice!

Now we're probably good to go, can you re-open this PR?

@amab8901
Copy link
Contributor Author

amab8901 commented Dec 5, 2022

the button to reopen PR is deactivated
image
I probably need to open a new PR

@irevoire
Copy link
Member

irevoire commented Dec 5, 2022

Ah yeah, probably; go on, this time it should works!

bors bot added a commit that referenced this pull request Dec 5, 2022
722: Geosearch for zero radius r=irevoire a=amab8901

# Pull Request

## Related issue
Fixes #3167 (meilisearch/meilisearch#3167)

## What does this PR do?
- allows Geosearch with zero radius to return the specified location when the coordinates match perfectly (instead of returning nothing). See link for more details.
- new attempt on #713

## PR checklist
Please check if your PR fulfills the following requirements:
- [ X ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [ X ] Have you read the contributing guidelines?
- [ X ] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: amab8901 <amab8901@protonmail.com>
Co-authored-by: Tamo <irevoire@protonmail.ch>
Kerollmops pushed a commit that referenced this pull request Dec 6, 2022
722: Geosearch for zero radius r=irevoire a=amab8901

# Pull Request

## Related issue
Fixes #3167 (meilisearch/meilisearch#3167)

## What does this PR do?
- allows Geosearch with zero radius to return the specified location when the coordinates match perfectly (instead of returning nothing). See link for more details.
- new attempt on #713

## PR checklist
Please check if your PR fulfills the following requirements:
- [ X ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [ X ] Have you read the contributing guidelines?
- [ X ] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: amab8901 <amab8901@protonmail.com>
Co-authored-by: Tamo <irevoire@protonmail.ch>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working no breaking The related changes are not breaking (DB nor API)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants