Search code examples
lucenelevenshtein-distance

Is specific Lucene classes are intended to be consumed by applications?


I'm new to the Apache Lucene library. I'd like to directly consume a class in this library called: LevenshteinDistance to calculated similarity search between strings. Would that be correct for my own application to directly consume it, or should I go thru the Lucene api?


Solution

  • Just using that single class is totally ok, but if you just need that you should take the soure code of that class, remove unneded Lucene dependencies, and use it. Lucene is a huge thing and you don't want to have it in your project if you only needs to compute a string distance.

    One thing: In the source code for LevenshteinDistance.java there's a comment mentioning that the code was taken from Apache Commons "StringUtils" clas. Maybe you should just add that. It's here: https://commons.apache.org/proper/commons-lang/