JingsongLi commented on code in PR #11356:
URL: https://github.com/apache/paimon/pull/11356#discussion_r4662499175
##########
paimon-full-text/src/main/java/org/apache/paimon/fulltext/index/NativeFullTextGlobalIndexReader.java:
##########
@@ -94,6 +100,76 @@ public CompletableFuture<Optional<ScoredGlobalIndexResult>>
visitFullTextSearch(
executor);
}
+ private String nativeQuery(FullTextSearch search) throws IOException {
+ String nativeField = nativeTextField();
+ if (nativeField.equals(search.column())) {
+ return search.query();
+ }
+ // Archives use native field names, independently of the table column
name.
+ JsonNode query =
JsonSerdeUtil.OBJECT_MAPPER_INSTANCE.readTree(search.query());
+ rewriteColumn(query, search.column(), nativeField);
+ return JsonSerdeUtil.OBJECT_MAPPER_INSTANCE.writeValueAsString(query);
+ }
+
+ private String nativeTextField() throws IOException {
+ byte[] metadata = ioMeta.metadata();
+ if (metadata == null || metadata.length == 0) {
+ return "text";
+ }
+ JsonNode options =
JsonSerdeUtil.OBJECT_MAPPER_INSTANCE.readTree(metadata);
+ String field = "text";
+ String fields = null;
+ Iterator<Map.Entry<String, JsonNode>> entries = options.fields();
+ while (entries.hasNext()) {
+ Map.Entry<String, JsonNode> entry = entries.next();
+ String key = entry.getKey();
+ if (key.startsWith("fulltext.")) {
+ key = key.substring("fulltext.".length());
+ } else if (key.startsWith("tantivy.")) {
+ key = key.substring("tantivy.".length());
+ }
+ key = key.trim().toLowerCase(Locale.ROOT).replace('_', '-');
+ if ("text-field".equals(key)) {
+ field = entry.getValue().asText().trim();
+ } else if ("text-fields".equals(key) || "columns".equals(key)) {
+ fields = entry.getValue().asText();
Review Comment:
**[P2] Resolve the mapped field from the native archive.** Both
`full-text.text-fields` and `full-text.columns` can reach the writer, for
example from a catalog default and a table override using a different alias.
With `text-fields=body` and `columns=title`, I built two archives from the same
options using the pinned JNI dependency. The native writer resolved the first
field to `body` in one archive and `title` in the other. Both worked with their
actual native field. This code always rewrote the table column `content` to
`title`, so the first archive failed with `column 'title' is not configured for
this index`. The native builder applies aliases while iterating a Rust
`HashMap`. Please use the resolved configuration stored in the archive so
existing files can be read consistently. [Native option
handling](https://github.com/apache/paimon-full-text/blob/ad2ee8862d0dd33b578052bde6a862d6be55f5f2/core/src/config.rs#L56-L75)
##########
paimon-full-text/README.md:
##########
@@ -92,7 +92,10 @@ All integers are **big-endian**.
1. `NativeFullTextGlobalIndexReader` opens the archive file as a
`SeekableInputStream`.
2. The stream is passed to `paimon-full-text-index`'s `FullTextIndexReader`
through a positional read adapter.
3. The native reader reads file data on demand through `pread` callbacks
backed by Paimon's file IO. No temp files are created in Paimon.
-4. Search queries are converted to the native single-column query JSON and
executed with BM25 scoring, returning `(rowId, score)` pairs.
+4. Query JSON references to the selected table column (`column` or `columns`)
are mapped to the
+ native field name (`text` by default, or the field configured when the
index was built).
+ Queries that omit the field name use the native default field. Searches
execute with BM25
Review Comment:
**[P2] Clarify when an omitted field is accepted.** With a native archive
configured with `text-fields=body,title`, I ran a `match` query without
`column` and it matched. A `phrase` query without `column` failed with `column
must be set for multi-field indexes`. Please qualify the default-field
statement for multi-field indexes and query types that require an explicit
column.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]