John John
John John

Reputation: 1

Improving string searching

I have a table named “Articles” which contains an Article_body field which might contain more than 1000 characters for each record. And i have a search web page to search these articles by inserting any string and retrieve all the articles that contains this string in their Article_body field .i am currently doing this using the .contain method as following:-

**public IQueryable<Question> searcharticles(string q)
    {
        return from a in entities1.articles
            where (a.article_body.Contains(q)  
 select u;}**

Currently the search is working fine, but i am afraid that when i will have thousands of articles this might not work efficiently, so i have the following two questions:-

  1. is there a better way to do the search ?.
  2. if i add a index on the article_body field will it speed up the search (i do not think so!!)? Thanks in advance for any help. BR

Upvotes: 0

Views: 97

Answers (2)

dotnetstep
dotnetstep

Reputation: 17485

Assuming that you have SQL Server

There are couple of way you can improve performance.

  1. Create proper non-clustered index with covering column as well.

    ( Read about cover index)

  2. Full Text Search of SQL Server but this require enterprise licence if you want to host online

  3. Try Lucene Indexing

Upvotes: 3

M.Babcock
M.Babcock

Reputation: 18965

Have you looked into Full Text Search (assuming your database is SQL server)?

Upvotes: 3

Related Questions