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

Meilisearch #3

Open
irevoire opened this issue Apr 26, 2023 · 4 comments
Open

Meilisearch #3

irevoire opened this issue Apr 26, 2023 · 4 comments

Comments

@irevoire
Copy link

irevoire commented Apr 26, 2023

Hey, I've just seen your blogpost. It's awesome!

I can't really submit a PR because I don't know much about golang, but I see you had some issues with meilisearch, and I thought I could help!

1. This benchmark is totally unfair for Meilisearch since their API expects it to be batched

I don't think that's entirely true. Meilisearch can autobatch your updates on its side. The issue in your code is that between each update submitted to meilisearch, you wait until the task is processed:

		task, err := index.AddDocuments([]map[string]interface{}{
			{"id": id, "_geo": []any{lat, long}},
		})
		L.IsError(err, `index.AddDocuments`)
		if err == nil {
			_, err := client.WaitForTask(task.TaskUID) // <- you should not wait here
			L.IsError(err, `client.WaitForTask AddDocuments`) 
			return err
		}

As you said, ideally, you should batch your updates as much as possible. But if you don't, meilisearch should still be able to handle your data pretty fast.

In your case, I think the sensible thing would be to WaitForTask only once after inserting the 100k points.

2. MeiliSearch, in this case, always returns 0 results. Not sure what's wrong.

I don't really understand what's wrong either yet.

I've seen this comment, though;

		// _geoBoundingBox: [minLat, minLong, maxLat, maxLong] --> didn't work

And this is wrong, this is the accepted format by meilisearch;

Filter documents by a given geo bounding box using the built-in filter _geoBoundingBox([{lat}, {lng}], [{lat, lng}]). The first pair of coordinates represents the top right corner of the bounding box, while the second pair represents the bottom left corner.

So in your case, you should send something like that _geoBoundingBox([maxLat, maxLong], [minLong, minLat])


		// TODO: need to calculate distance manually (~10% overhead)
		return uint64(len(res.Hits)), nil

I don't really understand this comment either, but if you were looking for the distance between your initial point and the results, meilisearch already computes that for you. It's added in all of your hits under the field _geoDistance.


Don't hesitate if you have any questions!

@kokizzu
Copy link
Owner

kokizzu commented Apr 26, 2023

ok will modify at weekend for the batch part
for 2nd part, oh so lat-long long-lat '__') or [lat,long], [lat,long] --> will try modify it that way

@kokizzu
Copy link
Owner

kokizzu commented Apr 26, 2023

a bit faster when only waiting last one
INSERTED 100K points: ok 98960 (100.0%) in 193.6 sec, 511.0 rps, ERR: 0

for geoBoundingBox also still the same, 0 result

@irevoire
Copy link
Author

that's really strange. Are there instructions somewhere on how to run it on my side?

@kokizzu
Copy link
Owner

kokizzu commented Apr 27, 2023

you can install golang, clone the repo, run

cd 2023geo/meilisearch
go mod tidy # to download dependencies)
docker-compose up
go run geomeilisearch.go 

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

2 participants