Fuzzy search : matching prefix of the specified length

239 views
Skip to first unread message

y cho

unread,
Mar 4, 2018, 2:55:00 AM3/4/18
to bleve
Hi Bleve,
Thank you for making this amazing piece of software! It s incredibely easy to get started!

I d like to use prefix in fuzzy queries.

In the documentation there http://www.blevesearch.com/docs/Query/, it says " Also, you can optionally specify that the term must have a matching prefix of the specified length."
Therefore I have tried setting options "prefix" without any luck.
Could you explain how to use prefix with the fuzzy search ?

My attempt to fuzzy prefix :

query := bleve.NewFuzzyQuery(u.Name)
    query.SetPrefix(4)
    query.Prefix = 4


When I search for "inter" I don t get results for "international" where as with simple prefix query I do.

Thanks for your help

y cho

unread,
Mar 4, 2018, 7:56:00 AM3/4/18
to bleve
Maybe it s the documentation request there is here ? :
Then is the approch from "harobeb" the good one ?

"

harobed commented on Jan 13, 2016

Example, I've "foobar" in my input data, I would like that "foo" match "foobar".

"


https://github.com/blevesearch/bleve/issues/321


Marty Schoch

unread,
Mar 5, 2018, 6:09:36 PM3/5/18
to bl...@googlegroups.com
So, the fuzzy search optionally supports matching a prefix as well, but it ALWAYS does the fuzzy matching (with default fuzziness of 1).

So, when you set query.Prefix to 4, you're saying the first 4 characters MUST match exactly.  But that is not enough, the rest of the term MUST still satisfy the fuzziness requirement.  In your example you did not alter the fuzziness, so it defaults to 1.  But, "international" is not edit distance of 1 away from "inter" even though it does satisfy the prefix requirement (4).

That is why the query you ran did not produce the result you expected.  But, I'm still not clear what you're trying to do exactly.  It's possible that fuzzy query isn't the best approach.

marty

--
You received this message because you are subscribed to the Google Groups "bleve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bleve+unsubscribe@googlegroups.com.
To post to this group, send email to bl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bleve/ee5c0240-3dfe-4263-adf6-b664c6296639%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages