Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 274
Matt Avatar asked Oct 27 '25 02:10

Matt


1 Answers

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.

like image 105
Ed Power Avatar answered Oct 28 '25 16:10

Ed Power



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!