我正在尝试使用弹性搜索而不是mysql进行全文搜索(目前它很慢),所以我只是制作演示而且我发现mysql表现更好。
但我怀疑我做错了什么
到现在为止我做了什么: -
本地主机:9200 / elastic_analysis_pattern / _settings
{
"elastic_analysis_pattern": {
"settings": {
"index": {
"creation_date": "1459959233955",
"analysis": {
"filter": {
"edge_ngram": {
"min_gram": "2",
"side": "front",
"type": "edgeNGram",localhost:9200/elastic_analysis_pattern/_mapping/
"max_gram": "20"
}
},
"analyzer": {
"pattern_index": {
"filter": [
"lowercase",
"stop",
"edge_ngram"
],
"tokenizer": "pattern_token"
},
"pattern_search": {
"filter": [
"lowercase",
"stop"
],
"tokenizer": "whitespace_token"
}
},
"tokenizer": {
"whitespace_token": {
"type": "whitespace"
},
"pattern_token": {
"pattern": "[^\\p{L}\\d]+",
"type": "pattern"
}
}
},
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "109pq9KfTVq32rIydKMPtg",
"version": {
"created": "2020199"
}
}
}
}
}
本地主机:9200 / elastic_analysis_pattern / _mapping /
{
"elastic_analysis_pattern": {
"mappings": {
"search_analysis": {
"properties": {
"search": {
"type": "string",
"analyzer": "pattern_index",
"search_analyzer": "pattern_search"
}
}
}
}
}
}
我正在搜索的查询是: -
{
"query" : {
"bool" : {
"must" : {
"query_string" : {
"query" : "sho",
"default_field" => "search"
}
}
}
},
"size" => 10
}
和mysql查询是:
SELECT SQL_NO_CACHE * FROM internet_ads WHERE (MATCH (search) AGAINST (' +sho*' IN BOOLEAN MODE)) LIMIT 0,10
我正在使用大约有60,000行的数据库进行测试
exectution时间
弹性时间 = 0.034985065460205
mysql时间 = 0.01869797706604
任何人都可以告诉我,如果我在这里做错了。
非常感谢任何帮助。