下列四种搜索客户端实现中哪种写法更合理?
//方案一:
$mustFilter = Filter::getMustFilter();
$shouldFilter = Filter::getShouldFilter();
$notMustFilter = Filter::getNotMustFilter();
$queryFilter = Filter::getQueryFilter();
$mustFilter
->setTerm($termParmas)
->setTerms($termsParmas)
->setRange($rangeParams);
$queryParams = Filter::init($alias)
->addFilter($mustFilter)
->addFilter($shouldFilter)
->addFilter($notMustFilter)
->addFilter($queryFilter)
->setSort($sortParams)
->setLimit($from, $size)
->build();
$result = Searcher::search($queryParams);
//方案二:
Eql::getInstance()
->setMust()
->add('goog', 'eq', 1)
->add('a', '>', 2)
->setShould()
->add('goog', 'eq', 1)
->add('a', '>', 2)
->query('keyword');
//方案三:
Eql::query([
['a','eq', 1, 'must'],
['b','eq', 1, 'must'],
['c','eq', 1, 'should'],
['d','eq', 1, 'should'],
]);
//方案四:
$searcher = Searcher::getInstance();
$query = new Query();
$query->setMustCondition($mustCondition)
->setMustNotCondition($mustNotCondition)
->setSort($sortCondition)
->setPageSize(10)
->getPage(1);
$result = $searcher->search($query);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论