simon28082 / elasticsearch Goto Github PK
View Code? Open in Web Editor NEWUse SQL statements to query elasticsearch
License: MIT License
Use SQL statements to query elasticsearch
License: MIT License
es 有账号密码时添加数据报错:
{"status":401,"message":"Can not find user: anonymous"}
创建索引时:
$hosts = [
config("elasticsearch.host")
];
$client = ClientBuilder::create()
->setHosts($hosts)
->setBasicAuthentication(config("elasticsearch.username"), config("elasticsearch.password"))
->build();
可以正常执行,那添加数据时,如何传递账号密码?
$this->builder->index($index);
composer下来后运行查询报错
product.ERROR: Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster in F:\WNMP\WWW\product_houtai_hn\vendor\elasticsearch\elasticsearch\src\Elasticsearch\ConnectionPool\StaticNoPingConnectionPool.php:53
Stack trace:
百度好久了找不到解决方法呃。。。
public function get(): Collection
{
$results = $this->runQuery($this->grammar->compileSelect($this));
return $this->metaData($results);
}
protected function metaData(array $results): Collection
{
return collect($results['hits']['hits'])->map(function ($hit) {
return $this->sourceToObject($hit);
});
}
这里直接抛弃了 aggregations
中的数据,仅返回 hits 数据么,那我该怎么获取aggregations
中的数据呢?
query:
$builder = $this->builder->index('index')->type('type');
$result = $builder->whereTerm('id',10015)->first();
error:
Call to undefined function CrCms\ElasticSearch\array_pull()
at vendor/crcms/elasticsearch/src/Grammar.php:62
如题,没有找到bluk的相关操作
$maxPage = intval(ceil($results['hits']['total'] / $perPage));
return collect([
'total' => $results['hits']['total'],
'per_page' => $perPage,
'current_page' => $page,
'next_page' => $page < $maxPage ? $page + 1 : $maxPage,
//'last_page' => $maxPage,
'total_pages' => $maxPage,
'from' => $from,
'to' => $from + $perPage,
'data' => $data,
]);
应改为
$maxPage = intval(ceil($results['hits']['total']['value'] / $perPage));
return collect([
'total' => $results['hits']['total']['value'],
'per_page' => $perPage,
'current_page' => $page,
'next_page' => $page < $maxPage ? $page + 1 : $maxPage,
//'last_page' => $maxPage,
'total_pages' => $maxPage,
'from' => $from,
'to' => $from + $perPage,
'data' => $data,
]);
因为$results打印为
array:4 [▼
"took" => 5
"timed_out" => false
"_shards" => array:4 [▼
"total" => 1
"successful" => 1
"skipped" => 0
"failed" => 0
]
"hits" => array:3 [▼
"total" => array:2 [▼
"value" => 176
"relation" => "eq"
]
"max_score" => 1.0
"hits" => array:15 [▶]
]
]
Will ES 7 support be done
thank you so much
public function orWhereMatch($field, $value, $boolean = 'and'): self
{
return $this->whereMatch($field, $value, $boolean);
}
应该是:
public function orWhereMatch($field, $value, $boolean = 'or'): self
{
return $this->whereMatch($field, $value, $boolean);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.