Skip to content

Dev - #1

Closed
ykan821 wants to merge 24 commits into
masterfrom
dev
Closed

Dev#1
ykan821 wants to merge 24 commits into
masterfrom
dev

Conversation

@ykan821

@ykan821 ykan821 commented Jun 23, 2026

Copy link
Copy Markdown
Owner

No description provided.

ykan821 and others added 24 commits June 8, 2026 23:33
用 ES 文档 create (op_type=create) 实现分布式锁:
- run() 自动加锁/解锁 (try/finally)
- forceUnlock() 手动释放残留锁
- isLocked() 查询锁状态
- ensureLockIndex() 自动创建 .ek_locks 系统索引

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
first()/scroll()/paginate()/aggregateScalar() 在 doSearch() 异常时
未能恢复 query 状态,改为 try-finally 确保恢复。

count() 对 ES 响应缺失 count 字段时抛 RuntimeException。
- Boolean/DisjunctionMax/SpanOr/SpanNear 的 must()/should()/filter() 等改为追加语义
- 每个 clause key 持有一个 Query(multi=true),闭包透传同一对象
- Query 实例通过 addQuery() 存入,buildQuery() 展平取子句
- 新增 Query::getQueries(),_queryClauses 重命名为 _queries
- 移除 Compound::wrapQueryAsClosure()
- 新增 totalRelation() 直接映射 hits.total.relation
- aggregations() 缺省返回 null 替代空数组,语义更准确
- hasMore() 确认无 bug,scroll 场景 !empty(hits) 正确

Co-Authored-By: Claude <noreply@anthropic.com>
- rollback() 移除所有 backing index 的别名,对齐 doRun() 写法
- name() 在子类未设置 $name 时抛出异常

Co-Authored-By: Claude <noreply@anthropic.com>
- Node: 提取 fromKeyValue/fromClosure/fromArrayField/fromScalar
- Query: 复用 fromClosure,新增 fromArray 处理 query key
- 构造函数变为清晰的路由表,每个方法只处理一种输入形式
- 更新 CLAUDE.md 待办完成状态

Co-Authored-By: Claude <noreply@anthropic.com>
…ed 事件

- Bulk 新增 onError(callable),execute() 默认 throw on errors
- Rebuild 删 skipErrors,新增 onError(callable),内部委托给 Bulk
- 删 rebuild.import.failed 事件,错误处理统一走 onError 回调
- batchSize auto-flush 的错误也通过 onError 捕获,不再丢失
- 更新文档和待办

Co-Authored-By: Claude <noreply@anthropic.com>
Index 静态方法保留作 @deprecated 代理,调用点迁移到新类。
测试 ReflectionProperty 替换为新类的 reset()。
- 移除 Index::insert(),等价功能由 Doc::save() 覆盖
- 移除 6 个 deprecated 代理方法(listen/dispatch/setPageResolver 等)
- 新增 on(string $connection)、newQuery()、newDoc() 实例方法
- 新增 setConnection()/getConnection() 实例方法
- query()/doc() 改为委托 newQuery()/newDoc()
- ClientManager 删除隐式 fallback,补类型声明
- 更新测试和 README
全 12 文件 declare(strict_types=1) + 构造器属性提升 + readonly + native 属性/返回/参数类型 + 联合类型。

主要变更:
- 修复 Manager::resolveIndexName() 空别名映射 null→TypeError(array_key_first() ?? $name)
- Doc $id 支持 string|int|null:index/create 省略 id 由 ES 自动生成,
  get/source/exists/update/delete 用 requireId() 守卫(治住静默发 null id 到 ES 的隐患)
- Bulk::execute() 加 json_encode false 守卫(strict_types 下防 strlen(false) TypeError)
- callable 属性(resolver/errorHandler/dataSource)保留 docblock(PHP 禁止 callable 作属性类型)

同步:TestConcreteIndex 与 docs 示例属性类型化;CLAUDE.md 待办拆分 Index/DSL 两层。

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- strict_types 全 151 文件;$_key/$_valueKey/$_fieldKeyed/$_multi 4 原子属性
  类型同步全部 leaf;leaf 参数类型对照 ES docblock 补齐
- $_properties 统一为 ?array,新增 $_raw 承接整体透传
- $_isPropertyField → $_fieldKeyed,统一命名风格(与 $_multi 对齐)
- 删 setMulti 死方法(Node/Query),multi() 统一承担
- 删 30 个与基类等价的 field() override,保留 Highlight
- AdjacencyMatrix/Composite 清理冗余属性与 toArray,序列化下沉 resolveProperties

Co-Authored-By: Claude <noreply@anthropic.com>
- FilterAgg/GlobalAgg/ParentAgg 重命名为 Filter/Global_/Parent_(去 Agg 后缀对齐 ES 关键字,global/parent 为 PHP 保留字加 _)
- setFilter()/globalAggregation() 改名 filter()/global()
- Node 移除 $_raw 整体透传机制,$_rawValue 重命名为 $_value 并加联合类型;scalar 构造分支不再限定 _fieldKeyed
- Query 同步移除 $_raw 分支;新增 rector.php 现代化规则配置

Co-Authored-By: Claude <noreply@anthropic.com>
所有非 trait class 的单参数 public 方法参数名统一为 $value,
避免 named arguments BC 风险。多参数方法和 trait 通用方法不受影响。

- 批量重命名约 350 个方法参数(含 docblock 和方法体同步)
- 删除 Knn::boost() 重复方法
- 修复 Suggest docblock 类型写法不一致(string|null → ?string)
- 修复 PHP_CS_FIXER_IGNORE_ENV 废弃警告
补全 intervals 查询缺失的 regexp 规则,对齐 ES 文档顺序置于 wildcard 与 fuzzy 之间。新增 Regexp leaf(pattern/analyzer/useField)。

Co-Authored-By: Claude <noreply@anthropic.com>
延续 2e18121(leaf setter 统一为 $value),将参数命名推广到 Query/Param/Agg/Function 等 non-leaf 层及全部 builder trait:

- Param:26 个单参 setter 改 $value;sort() 改纯追加语义;indices_boost 改追加模式(链式多次调用累加而非覆盖);sort docblock 修正
- Agg:$subAggs → $_subAggs;node/alias/toArray 补类型声明
- trait(Compound/Span/Specialized/FullText/Joining/MatchAll/TermLevel/Aggs):单参 builder 统一 $value;Bucket::filter 同步
- Function_:4 个 decay 方法第二参改 $value

Co-Authored-By: Claude <noreply@anthropic.com>
- $name → $connection(ClientManager::set / Index::setClient)
- $newName → $newIndex(Rebuild,对齐 <role>Index 模式)
- $document → $data(Doc/Bulk 的 index/save/create,全库文档载荷统一)
- Rebuild::source 补 callable|iterable 参数类型,修正 docblock \Iterator 笔误

Co-Authored-By: Claude <noreply@anthropic.com>
- 原 cursor()(按批 yield Results)改名为 chunk()
- 新增 cursor():逐条 yield 完整 hit(_id/_score/_source),flatten chunk 复用其 scroll 清理
- 低层 scroll/next/clear 保留,未来可换 PIT+search_after,上层签名不变
- 同步 README/docs/IndexTest

**BC:** cursor() 返回从 Generator<Results>(按批)改为 Generator<hit>(逐条)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- run() 分离 try-catch:失败优先抛 doRun 原始异常(释放锁失败不掩盖);
  成功后释放锁失败抛 RuntimeException(说明 rebuild 已完成、需 forceUnlock)
- releaseLock 移除 \Throwable 兜底,只吞 404
- forceUnlock 独立实现,吞 404(索引或文档不存在均幂等成功)
- isLocked 只在 404 返回 false,其他 ES 错误传播

**BC:** forceUnlock/isLocked 不再吞非 404 的 ES 错误;run() 成功路径
在释放锁失败时抛出异常(此前被静默吞掉)

Co-Authored-By: Claude <noreply@anthropic.com>
- phpunit.xml 改用 PHPUnit 10 schema 声明 + cacheDirectory
- .gitignore 收纳 .phpunit.cache/
- CLAUDE.md:Rebuild 异常处理、cursor/chunk API 重构标记完成

Co-Authored-By: Claude <noreply@anthropic.com>
@ykan821 ykan821 closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant