Possible to use Linq to query a column that contains a description and remove the whitespaces?
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
It would be a very slow solution. Assuming t-sql, I would add a computed column and put an index on it.
Wrong is evil and must be defeated. - Jeff Ello
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
I would suggest holding a table of synonyms, with possible search terms pointing to the actual terms in the product description
========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
Guess the original idea I had might be the best. A separate table of straight text with no white spaces and just do a join. Or maybe a table of words with white space that are parsed out with conjunctions removed and verbs fixed. Alright Thanks!
If it ain't broke don't fix it
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
As I read this you have decided on a solution and now are attempting to implement that. My take on the problem, not your solution, is that you should investigate it first and then decide on a solution to implement. Your problem is not new. It has been around for decades and I doubt your solution will work. For starters because it doesn't really deal with misspellings. Not to mention synonyms. However there are solutions that do work fairly well. So you should see if you can find them first.
-
Boy that was a mouth full. Let me explain. I have a table of products with names and descriptions. So take a word like kneepads. The correct way to spell it is knee pads and the column contains that correct spelling. But users will type in kneepads to search. I solved the plural issue with a custom function that I wrote. But I'm wondering if I can query the database in Linq, and say something like without removing, replacing a value in the database from pr in context.PRODUCT_ITEMS WHERE pr.Name.Replace(" ", "").Contains("kneepad") Basically I'm just looking for ideas to handle this. My older program had another table that contains names and descriptions that were pre-stripped for searching and I really don't want to go back to that.
If it ain't broke don't fix it
Something along these lines will work:
List words = new List() { "hEllo", "World" }; words = words.Select(x => x.Replace("hE", "He")).ToList();
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens