Skip to content

Meilisearch #3

Open
Open
@irevoire

Description

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!

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions