mysql - Is there a fast way to do a '%phrase%' search in any DB? -


i have large dataset 5m rows. 1 of fields in dataset 'article_title', i'd search in real-time autocomplete feature i'm building on site.

i've been experimenting mysql , mongodb potential db solutions. both perform when index used, example 'something%', need match titles within string, in '%something%'.

both mysql , mongodb took 0.01 seconds index using forward-looking search, , 6 seconds full string search.

i realize entire db needs scanned string-in-string type search common approach problem? solr , sphinx seem overkill 1 problem i'm trying avoid using them if possible.

if got box 2 gb of ram , 40gb ssd (which can afford @ moment), able sub-second response time? in advance.

--

update: tried fulltext index , while results fast, doesn't satisfy string-in-string search ("presiden" doesn't match "president"). i'm looking ways match string-in-string 5m row dataset.

in case of mysql, can create full-text index. put simply, full-text index makes partial text matches fast indexing each word. create index write:

alter table yourtable add fulltext index(article_title); 

after can search with:

select * yourtable match(article_title) against ('something'); 

it seems mongodb has text indexes. imagine indexing can fine-tuned in either case, you'll have test better case.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -