網(wǎng)站公安備案 工信備案seo優(yōu)化一般多少錢
由于經(jīng)常編寫復(fù)雜的 Elasticsearch 查詢,并通過代碼生成查詢條件,我發(fā)現(xiàn)每次使用 curl 請求 Elasticsearch 時,手動復(fù)制配置信息并構(gòu)建 curl 命令的過程非常繁瑣,尤其是在管理多個環(huán)境的情況下更為不便。因此,我利用 AI 技術(shù)開發(fā)了一款 Web 工具,經(jīng)過一系列優(yōu)化和改進(jìn),該工具能夠智能拼接配置信息,自動生成完整的 Elasticsearch curl 命令,極大提升了工作效率。
訪問地址可直接使用(需科學(xué)上網(wǎng)) https://avidbyte.github.io/ESCurlGen/
功能介紹 測試示例 my_user_index 索引
1.創(chuàng)建索引
{"mappings": {"properties": {"id": { "type": "keyword" },"name": { "type": "text", "fields": { "keyword": { "type": "keyword" } } },"phone": { "type": "text", "fields": { "keyword": { "type": "keyword" } } },"birthday": { "type": "date" },"createTime": { "type": "date" }}}
}
2.新增索引字段
{"properties": {"address": { "type": "text", "fields": { "keyword": { "type": "keyword" } } }}
}
3.查詢 settings
4.查詢 Mapping
5.新增數(shù)據(jù)
{"id": "1","name": "John Doe","phone": "123-456-7890","birthday": "1990-01-01","createTime": "2023-10-10T08:00:00Z","address": "123 Main St"
}
{"id": "2","name": "Jane Smith","phone": "098-765-4321","birthday": "1985-05-05","createTime": "2023-10-11T09:00:00Z","address": "456 Oak Ave"
}
6.批量操作(批量新增)
{ "index": { "_id": "3" } }
{ "name": "User One", "phone": "1234567890", "birthday": "1995-05-05", "createTime": "2024-10-17T10:00:00", "address": "789 Elm St" }
{ "index": { "_id": "4" } }
{ "name": "User Two", "phone": "0987654321", "birthday": "1988-07-15", "createTime": "2024-10-17T11:00:00", "address": "1234 Oak St" }
7.查詢索引數(shù)據(jù)條數(shù)
8.根據(jù)條件查詢
{"query": {"match": {"name": "John Doe"}}
}
9.根據(jù) ID 查詢
10.滾動查詢
{"size": 2,"query": {"match_all": {}}
}
在初次滾動查詢后,您需要使用 scroll_id 進(jìn)行后續(xù)請求:
{"scroll": "1m","scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAA..."
}
11.根據(jù) ID 更新數(shù)據(jù)
{"doc": {"phone": "555-555-5555","createTime": "2024-10-17T00:00:00Z"}
}
12.根據(jù)自定義條件更新數(shù)據(jù)
{"query": {"match": {"name": "Jane Doe"}},"script": {"source": "ctx._source.phone = params.phone; ctx._source.address = params.address","params": {"phone": "5555555555","address": "222 Elm St"},"lang": "painless"}
}
13.根據(jù) ID 刪除數(shù)據(jù)
14.根據(jù)自定義條件刪除數(shù)據(jù)
{"query": {"match": {"name": "Jane Doe"}}
}