如果我想要somefield
为12345的文档,则可以执行"query": { "term" : {"somefield" : {"value": 12345 }}}
或"query": {"match" : {"somefield": 12345 }}
。哪个更快?
在ElasticSearch中搜索固定数值
•
问答
wearcoll658 回答:在ElasticSearch中搜索固定数值
仅当您将std::map<std::string,int> answers;
int count_answers( const std::string &question)
{
auto &value = answers.insert( {question,42}).first->second;
return ++value;
}
int main() {
std::cout << count_answers( "Life,the universe and everything") << '\n';
std::cout << count_answers( "Life,the universe and everything") << '\n';
return 0;
}
查询为try_emplace
或term
类型之一并将其索引比keyword
更快时,才能使用numeric
查询。最快的将是match
查询。它不会影响文档评分。
filter