c# - Show similar products or variants -
i want show similar products called variants product. doing below:
public ilist<product> getvariants(string productname) { efcontext db = new efcontext(); //using entity framework return db.products .where(product = > product.productname == productname) .tolist(); }
but , results exact match, current product itself. thinking use levenshtein distance basis similar products. , before want check majority developers getting variants?
- is use levenshtein distance ? used in industry purpose?
- do have add table in database showing variants product while adding product database?
i used jaro-winkler distance account typos in 1 system wrote while back. imo, it's better simple edit distance calculation can account string lengths effectively. see this question on open source implementations.
i ended writing in c# , importing sql server sql clr function, still relatively slow. worked in case because such queries executed infrequently (100-200 in day).
if expect lot of traffic, you'd have build index make these lookups faster. 1 strategy periodically compute distance between each pair of products each pair of products , store in index table if distance exceeds threshold. reduce amount of work needs done, can run once or twice day , can limit new or modified records since last run. can similar products , order distance quickly.
Comments
Post a Comment