PHP ???? Elasticsearch? ???? ??? ?? ? ??? ???? ?? ?
Oct 03, 2023 am 08:08 AMPHP ?? ? Elasticsearch ??? ?? ? ?? ?? ??
??: ????? ????? ??? ??? ?? ??? ??? ???? ?? ???? ????. PHP ???? Elasticsearch? ???? ??? ?? ? ??? ???? ?? ????? ??? ?????. ? ????? Elasticsearch? ???? ??? ?? ? ??? ???? ??? ???? ??? ? ? ???? ??? ? ??? ???? ?? ??? ?????.
1. ??
???? ?? ? ?? ??? ?? ???. ?? PHP ??? Elasticsearch? ???? ??? ?????. Composer? ???? Elasticsearch ????? ?????? ??? ? ????(?: "elasticsearch/elasticsearch": ">=6.0").
2. ??? ??? ??
??? ???? ???? ???? ???? ???? ??? ?? ?? ??? ??? ???? ?? ????. Elasticsearch? ??? ??? ?? ? ?? ??? ?? ?? ?? ?? ? ?? ?????. ? ?? ???? ??? ??? ?? ??? ??? ? ????.
3. ??? ??
?? ??? ???? ???? ???? ???. ???? ???? ???? ???? ? ???? Elasticsearch? ??? ?????. Elasticsearch? RESTful API? ???? ??? ???? JSON ???? Elasticsearch? ???? ???? ??? ? ????.
???? ?? ?? ??? ????.
require 'vendor/autoload.php'; $client = ElasticsearchClientBuilder::create()->build(); $params = [ 'index' => 'images', 'body' => [ 'mappings' => [ 'properties' => [ 'image' => [ 'type' => 'binary', ], 'tags' => [ 'type' => 'keyword', ], ], ], ], ]; $response = $client->indices()->create($params);
?? ?? ??? images
?? ???? ???? image
(??? ???? ???? ? ???) ? < code>tags (???? ???? ? ???? ?? ?? ??). images
的索引,并定義了兩個字段 image
(用于存儲圖像數據)和 tags
(用于標記圖像的相關標簽信息)。
四、上傳圖像數據
接下來,我們需要將圖像數據上傳到 Elasticsearch 中??梢允褂?Elasticsearch 的 RESTful API,通過 HTTP 請求的方式將圖像數據發(fā)送給 Elasticsearch。
具體的代碼示例如下:
$imageData = file_get_contents('/path/to/image.jpg'); $params = [ 'index' => 'images', 'body' => [ 'image' => base64_encode($imageData), 'tags' => ['sunset', 'beach'], ], ]; $response = $client->index($params);
以上代碼片段將圖像數據以 base64
編碼方式存儲在 Elasticsearch 中,并使用 tags
字段關聯相關標簽信息。
五、圖像搜索
當圖像數據上傳完成后,我們可以通過 Elasticsearch 進行圖像搜索。使用 Elasticsearch 的搜索 API,我們可以利用圖像的特征進行搜索,并返回與搜索結果最匹配的圖像數據。
具體的代碼示例如下:
$params = [ 'index' => 'images', 'body' => [ 'query' => [ 'match' => [ 'tags' => 'sunset', ], ], ], ]; $response = $client->search($params);
以上代碼片段將使用 tags
字段進行搜索,匹配標簽為 sunset
???? ??? ???? Elasticsearch? ????? ???. Elasticsearch? RESTful API? ???? HTTP ??? ?? ??? ???? Elasticsearch? ?? ? ????.
require 'vendor/autoload.php'; $graph = new TensorFlowGraph(); $graph->import(new TensorFlowFilesystemLoader('path/to/model.pb')); $tensor = $graph->createTensorFromPath('path/to/image.jpg'); $session = new TensorFlowSession($graph); $output = $session->return([$tensor]); $prediction = $output[0]->data(); $params = [ 'index' => 'images', 'body' => [ 'query' => [ 'match' => [ 'prediction' => $prediction, ], ], ], ]; $response = $client->search($params);? ?? ??? Elasticsearch? ??? ????
base64
????? ????, tags
??? ???? ?? ??? ?????. ??. 5. ??? ????? ???? ???? ? Elasticsearch? ?? ??? ??? ??? ? ????. Elasticsearch? ?? API? ???? ???? ??? ???? ?? ??? ?? ???? ??? ???? ???? ??? ? ????.
???? ?? ?? ??? ????.
rrreee???? ?? ???tags
??? ???? sunset
??? ?? ??? ???? ???? ??????. ????6. ??? ?? ??????? ??? ???? ??? ?? ???? ????? ???? ?? ??? ?? ??? ??? ??? ??? ? ????. TensorFlow ? Caffe? ?? ? ?? ?????? ???? ?? ??? ???? ??? ?? Elasticsearch?? ?? ??? ??? ? ????. ???????? ?? ?? ??? ????. ??rrreee??? ?? ??? TensorFlow ?????? ???? ??? ??? ????, ??? ???? ????, ?? ??? Elasticsearch ??? ??? ?????. ??????: PHP? Elasticsearch? ???? ??? ?? ? ?? ??? ??? ? ????. ?? ???? ??? ?? ??? ???? Elasticsearch? ????? ???. ???? ??? ??? ?? Elasticsearch? ??? ? ????. ??? ?? ???? ??? ?? ?? ?? ????? ?? ??? ?? ??? ??? ?? ????. ? ??? PHP ???? Elasticsearch? ??? ??? ?? ? ?? ??? ?? ?????. ????? ??? ??? ????. ???? (??: ?? ?? ??? ?? ? ??? ?? ?? ????. ?? ?? ??????? ?? ??? ?? ???? ???????.) ??? ??? PHP ???? Elasticsearch? ???? ??? ?? ? ??? ???? ?? ?? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











Java ??: ??? ?? ? ??? ?? ?? ??? ??: ??? ?? ? ?? ??? ??? ???? ?? ??? ?? ? ??? ??? ???? ??? ??? ???. ? ????? Java ??? ???? ??? ?? ? ??? ???? ??? ???? ???? ?? ??? ?????. 1. ??? ??? ?? ?? ??? ??? ??? ??? ???? ???? ???? ???? ???? ?? ??, ?? ?? ??? ???? ?? ????. ??? ??? ???? ?? ??? ?? ? ?? ???? ??? ?? ??? ???? ???.

Python?? ??? ?? ? ??? ???? ?? ??: ?? ??? ?? ??? ?? ? ??? ?? ???? ??? ??? ?????. Python? ??? ??? ?? ? ?? ?????? ?? ??? ?? ???? ?? ????? ?????. ? ????? ??? ?? ? ??? ?? Python? ???? ??? ???? ???? ?? ??? ?????. ??? ??: ??? ??? ??? ?? ??, ????? ?? ?? ?? ?? ???? ?? ??? ?? ? ??? ???? ???????. Python? PIL ?????(Pi

Go ? Goroutines? ???? ??? ??? ?? ??? ?? ??: ???? ??? ???? ??? ??? ??? ??? ?????. ??? ??? ?? ??? ? ??, ??, ?? ?? ??? ??? ???? ??? ? ????. ??? ??? ??? ???? ????? ??? ??? ?? ??? ????. ? ??? ???? ?? ? ???? Go ??? ???? ???? ??? ?? ??? ?? ???? ???? ??? ?????. ??: Go ??

PHP? Elasticsearch ?? ?? ?? ? ?? ???? ??: ? ????? ?? ?? ? ?? ????? ?? Elasticsearch ??????? ???? ??? ?????. ??? PHP ?? ??? ?? Elasticsearch ??????? ????, ??????? ?? ???? ??, Elasticsearch? ??? ?? ??? ???? ??? ?? ??? ???? ?????? ??? ?????. ??: ?? ?? ? ?? ?????

Python ?????? ???? Baidu? ??? ?? ????? ??? ???? ??? ?? ??? ???? ??? ?????. ??? ?? ???? ??? ?? ??? ?? ??? ?????. Baidu? ??? ??, ???, ?? ?? ? ?? ??? ?? ??? ? ?? ??? ??? ?? ?????? ?????. ? ????? Python ????? ??? ???? Baidu ??? ?? ?????? ???? ??? ?? ??? ???? ??? ?????. ?? Baidu ??? ????? ??????? ???

PHP? Elasticsearch? ???? ??? ?? ??? ?? ?? ??: ?? ??? ???? ?? ??? ???? ??? ?? ?? ??? ?????. ?? ??? ???? ??? ??? ????? ?? ?? ???? ???? ?? ???? ?? ??? ?????. ? ????? PHP? Elasticsearch? ???? ??? ?? ??? ?? ??? ?????. 1. ?? ???? ?? PHP? Elasticsearch? ???? ?? ? ?????? ???? ???.

?? ??: Go ?? ??? ???? ??? ??? ?? ?? ?? ???? ?? ???? ??? ?? ??? ??? ?????. ??? ???? ????? ??? Go ??? ??? ?? ??? ??? ? ?? ??? ??? ????. ? ????? ????? Go ?? ??? ???? ??? ??? ?? ??? ???? ?? ?? ???? ?????. ?? Go ?? ?? ??? ???? ???. Go ?? ?? ????(https://golang.org/)?? ?? ??? ???? ??? ? ????.

Elasticsearch ?? ??? ?? ?? ?? ? ?? ??: Elasticsearch? Lucene ??? ?? ?? ?? ???? ?? ?? ?? ? ??? ???? ??? ???? ?? ??? ??, ?? ??? ?? ?????. , ?? ??? ? ?? ????. ??? ??? Elasticsearch? ??? ? ?? ??? ???? ???? ?? ?? ???? ??? ?????. ? ????? Elasticsearch ?? ??? ??? ???? ?? ??? ???? ?????.
