url - Match a string from tons of patterns -


i want make system url matching. work in way:

the database contains many patterns. , metadata of pattern this:

pattern1, keyword  pattern2, keyword ... ... 

i have input url. htttp://example.com/blabla/111/2222/detail.htm

the system input , output keyword of matched pattern input url. there more 20,000 requests per second.

the thing need design pattern , database model. i've spend on 2 weeks in system.

i'm thinking match url in tree.

all nodes in tree able 2 kinds of output: node should continue matching url, or node know keyword should applied url.

each node connected callback(a script stored in db). different node have different behavior.

but thing have tons of patterns. think need have facility convert patterns thos "nodes". or @ least can build tree existing nodes patterns in db.

i'm still thinking tree generating. there should better way.

any ideas helpful. thank you!!!

you need 1 of industrial-strength string matching algorithms: http://en.wikipedia.org/wiki/string_searching_algorithm. don't think database-backed approach work because sounds need pattern matching, not exact prefix matching.

but if using prefix matching (the longest match beginning), can use prefix trie, trie. if you, use database persistent store, keep matching trie in memory.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -