Allow codec configuration on BranchIndexWriter (currently blocks Lucene suggest fields)

Đang mở
#7 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
64/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
clojure, java
Lĩnh vực
backend-api-design, search

Hướng nghiên cứu

Bắt đầu trong src/java/org/replikativ/scriptum/BranchIndexWriter.java tại createOver, create, open và forkLocked, sau đó lần theo các factory công khai tạo các instance IndexWriterConfig của chúng. Xem xét các entry point Clojure trong src/clojure/scriptum/core.clj, đặc biệt là create-index và open-store-index. Công việc được xem là hoàn tất khi codec tùy chọn được truyền đến mọi cấu hình writer, trong khi các giá trị mặc định hiện có vẫn không thay đổi, bao gồm cả các writer được tạo trong quá trình fork.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Checked against v0.1.30 (90dbd2a) / Lucene 10.3.2.

Problem

SuggestField
and ContextSuggestField
require a Codec
whose getPostingsFormatForField
returns a CompletionPostingsFormat
(Completion101PostingsFormat
for Lucene 10.3). That codec has to be set on the
IndexWriterConfig
before the IndexWriter
is constructed.

BranchIndexWriter
builds its IndexWriterConfig internally at four sites, and none of them call
setCodec:

Line Enclosing method
328 createOver
402 create
507 open
693 forkLocked

None of the public factories take a codec either; they stop at
create(basePath, branchName, analyzer, cryptoHash).

There is no post-construction escape hatch either.
getIndexWriter().getConfig()
returns a LiveIndexWriterConfig,
where the codec is read-only.

So a SuggestField can be handed to
addDocument(Iterable<? extends IndexableField>)
and will be accepted, but it cannot be indexed in a form
SuggestIndexSearcher
can query.

The read half already works.
openReader()
and openReaderAt(generation)
return a plain DirectoryReader,
which wraps in a SuggestIndexSearcher with no change to scriptum. Per-branch and
historical suggest queries come for free once the write path is unblocked.

Why it fits

Completion postings are ordinary per-segment files, so I would expect COW segment
sharing, fork, snapshot addresses and the merkle content-hash to cover them
unchanged. I have not tested that, and it is the part of this I am least sure of.
Autocomplete you can fork, or query at an older commit, seems like a reasonable
thing to want from a branched index, and ContextSuggestField maps onto
multi-tenant scoping.

Suggested shape

Accept an optional Codec on the create / createOver / open factories and
thread it to all four construction sites, with today's behavior as the default. An
IndexWriterConfig customizer such as a
UnaryOperator<IndexWriterConfig>
would be more general if you prefer that.

forkLocked
is the one I would watch. It builds a fresh config rather than inheriting the
parent's, so if it is missed a fork quietly loses its codec and only fails later,
at query time, on the branch rather than on main.

On the Clojure side this could be an option to
create-index
and open-store-index,
plus a :suggest field type in
add-doc.

lucene-suggest need not become a scriptum dependency. A codec parameter is
enough to let callers bring their own.

Two interactions to watch

  • BranchAwareMergePolicy
    will not merge all-shared segments, so segment count grows with branch and
    commit history. Completion FSTs are held per segment, so a suggest-heavy index
    would feel that as heap growth sooner than an ordinary index does.
  • For store-backed indices,
    warm!
    would want to cover the completion files. Otherwise a cold suggest query pays a
    round trip per file, like any other cold read.

I am happy to put up a PR if this shape sounds right. If you would rather expose
the whole IndexWriterConfig than just the codec, say so and I will follow that
instead.

Ngôn ngữ chính
Clojure
Star
20
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue tương tự

Thêm issue về Clojure

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.