-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hello, first of all, thanks for publishing this, looks to be a very interesting gem.
I'm wondering if it would be possible to return the matched text (or index of matched characters) along with the results? This would be useful in cases where a fuzzy match returns results, and I would want to highlight the matching text (or just show a snippet of text around the matching text for context) in the results.
In the readme it says:
"You may have noticed that search method returns only documents ids. This is by design. The documents themselves are not stored in the index."
So maybe this is not possible, but I figured I would ask anyway:
From your example:
brother = {
imdb_id: "tt0118767",
type: "/crime/Russia",
title: "Brother",
description: "An ex-soldier with a personal honor code enters the family crime business in St. Petersburg, Russia.",
duration: 99,
rating: 7.9,
release_date: Date.parse("December 12, 1997")
}
Right now, this is how the search returns:
index.search('bersonal coder', fuzzy_distance: 1)
=> ["tt0118767"]
It would be great to return something like:
index.search('bersonal coder', fuzzy_distance: 1)
=>
[{
"tt0118767": {
match_ranges: [[21, 28], [36, 39]]
}
}]
That way I could display the results in my search listing like:
An ex-soldier with a personal honor code enters the family crime business in St. Petersburg, Russia.
I haven't dug into the source yet to see if this is possible, but I figure you'd know the limitations better and might be able to provide some input on if this is feasible.