Mahuta
Relase 0.3.12
Mahuta (以前稱為 IPFS-Store)是一個函式庫,用於聚合和整合應用程式在 IPFS 網路上儲存的檔案或文件。它提供了一個解決方案,以方便的方式收集、儲存、索引、快取和搜尋系統處理的 IPFS 資料。
服務 | 掌握 | 發展 |
---|---|---|
CI狀態 | ||
測試覆蓋率 | ||
賓特雷 | ||
碼頭工人 | ||
聲納 |
這些說明將為您提供在本機電腦上啟動並執行的專案副本,以用於開發和測試目的。
Mahuta 取決於兩個組成部分:
了解如何運行這兩個元件 首先運行 IPFS 和 ElasticSearch
< repository >
< id >consensys-kauri</ id >
< name >consensys-kauri</ name >
< url >https://consensys.bintray.com/kauri/</ url >
</ repository >
< dependency >
< groupId >net.consensys.mahuta</ groupId >
< artifactId >mahuta-core</ artifactId >
< version >${MAHUTA_VERSION}</ version >
</ dependency >
< dependency >
< groupId >net.consensys.mahuta</ groupId >
< artifactId >mahuta-indexing-elasticsearch</ artifactId >
< version >${MAHUTA_VERSION}</ version >
</ dependency >
Mahuta mahuta = new MahutaFactory()
.configureStorage(IPFSService.connect("localhost", 5001))
.configureIndexer(ElasticSearchService.connect("localhost", 9300, "cluster-name"))
.defaultImplementation();
IndexingResponse response = mahuta.prepareStringIndexing("article", "## This is my first article")
.contentType("text/markdown")
.indexDocId("article-1")
.indexFields(ImmutableMap.of("title", "First Article", "author", "greg"))
.execute();
GetResponse response = mahuta.prepareGet()
.indexName("article")
.indexDocId("article-1")
.loadFile(true)
.execute();
SearchResponse response = mahuta.prepareSearch()
.indexName("article")
.query(Query.newQuery().equals("author", "greg"))
.pageRequest(PageRequest.of(0, 20))
.execute();
欲了解更多信息,Mahuta Java API
<dependency>
<groupId>net.consensys.mahuta</groupId>
<artifactId>mahuta-springdata</artifactId>
<version>${MAHUTA_VERSION}</version>
</dependency>
@IPFSDocument(index = "article", indexConfiguration = "article_mapping.json", indexContent = true)
public class Article {
@Id
private String id;
@Hash
private String hash;
@Fulltext
private String title;
@Fulltext
private String content;
@Indexfield
private Date createdAt;
@Indexfield
private String createdBy;
}
public class ArticleRepository extends MahutaRepositoryImpl<Article, String> {
public ArticleRepository(Mahuta mahuta) {
super(mahuta);
}
}
欲了解更多信息,Mahuta Spring Data
$ docker run -it --name mahuta
-p 8040:8040
-e MAHUTA_IPFS_HOST=ipfs
-e MAHUTA_ELASTICSEARCH_HOST=elasticsearch
gjeanmart/mahuta
查看文件以使用 Docker 配置 Mahuta HTTP-API。
若要存取 API 文檔,請前往 Mahuta HTTP API
article
curl -X POST
http://localhost:8040/mahuta/config/index/article
-H 'Content-Type: application/json'
成功響應:
{
"status": "SUCCESS"
}
curl -X POST
'http://localhost:8040/mahuta/index'
-H 'content-type: application/json'
-d '{"content":"# Hello world,n this is my first file stored on **IPFS**","indexName":"article","indexDocId":"hello_world","contentType":"text/markdown","index_fields":{"title":"Hello world","author":"Gregoire Jeanmart","votes":10,"date_created":1518700549,"tags":["general"]}}'
成功響應:
{
"indexName": "article",
"indexDocId": "hello_world",
"contentId": "QmWHR4e1JHMs2h7XtbDsS9r2oQkyuzVr5bHdkEMYiqfeNm",
"contentType": "text/markdown",
"content": null,
"pinned": true,
"indexFields": {
"title": "Hello world",
"author": "Gregoire Jeanmart",
"votes": 10,
"createAt": 1518700549,
"tags": [
"general"
]
},
"status": "SUCCESS"
}
curl -X POST
'http://localhost:8040/mahuta/query/search?index=article'
-H 'content-type: application/json'
-d '{"query":[{"name":"title","operation":"CONTAINS","value":"Hello"},{"name":"author.keyword","operation":"EQUALS","value":"Gregoire Jeanmart"},{"name":"votes","operation":"GT","value":"5"}]}'
成功響應:
{
"status": "SUCCESS",
"page": {
"pageRequest": {
"page": 0,
"size": 20,
"sort": null,
"direction": "ASC"
},
"elements": [
{
"metadata": {
"indexName": "article",
"indexDocId": "hello_world",
"contentId": "Qmd6VkHiLbLPncVQiewQe3SBP8rrG96HTkYkLbMzMe6tP2",
"contentType": "text/markdown",
"content": null,
"pinned": true,
"indexFields": {
"author": "Gregoire Jeanmart",
"votes": 10,
"title": "Hello world",
"createAt": 1518700549,
"tags": [
"general"
]
}
},
"payload": null
}
],
"totalElements": 1,
"totalPages": 1
}
}