Matt
Matt

Reputation: 27001

In memory text search using .NET

I have a couple megs of text in memory stored in a 2-D array, where the first column is the line number and the second column is the text itself. What I would like to do is find an existing solution where I could pass this sort of data structure (It's malleable) and a Boolean search query ideally with wildcards, and figure out which rows contain matches. Are there any APIs out there that do this? I don't want to use something like Lucene because I don't want to bother building an index. I basically want to enumerate through a collection of strings and return those that have hits against the query passed in.

Upvotes: 4

Views: 3486

Answers (2)

Ed Power
Ed Power

Reputation: 8531

If you're loading the data, searching it once, and then throwing it away, you're better off going the LINQ+RegEx route as suggested in the comments above. That is, you might as well do your search on the first pass through the data instead of making a pass to index the data then searching the index as a search engine would do.

But if you're going to load the data once and then repeatedly search it, then you're better off using a search engine. If you still don't want to use Lucene.Net, an in-memory System.Data.Sqlite database with full-text search would work well, too.

Upvotes: 6

tranceporter
tranceporter

Reputation: 2261

Would it be useful to store them in SQL server and use the methodology described in this document?

http://msdn.microsoft.com/en-us/library/ms142571.aspx

Upvotes: 0

Related Questions