Skip to content

[full-text] Fix table column names in native full-text queries - #11356

Open
zhoulii wants to merge 1 commit into
apache:masterfrom
zhoulii:fix/native-full-text-column-mapping
Open

zhoulii wants to merge 1 commit into
apache:masterfrom
zhoulii:fix/native-full-text-column-mapping

Conversation

@zhoulii

@zhoulii zhoulii commented Nov 23, 2026

Copy link
Copy Markdown
Member

Purpose

Queries that explicitly reference a table column, such as
{"match":{"column":"content","terms":"paimon"}}, fail because the native
index uses text by default.

Map table column references to the native field recorded in the index
metadata. Preserve query terms and support custom native field names
without changing existing index files.

Tests

Added native query tests for nested queries, row-ID filters, custom field
configuration, and unknown columns, plus a Data Evolution query regression.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed the table-column mapping fixes real Data Evolution searches, including reads spanning indexed and unindexed rows. The two focused Maven suites passed 31 tests with the benchmark skipped. The raw fallback replay and both primary-key archive controls also passed. The inline findings cover native field resolution and the README's omitted-column behavior.

if ("text-field".equals(key)) {
field = entry.getValue().asText().trim();
} else if ("text-fields".equals(key) || "columns".equals(key)) {
fields = entry.getValue().asText();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@zhoulii

zhoulii commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

The reader API is being added in apache/paimon-full-text#25.
I'll update this PR after that change is merged and a new version is released.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reproduced a compilation failure after integrating this revision with master (2be2aed46d). The existing native field-mapping feedback also remains relevant to this revision.

writer.write(BinaryString.fromString("content paimon lake"), 0);
writer.write(BinaryString.fromString("vector indexing"), 1);
writer.write(BinaryString.fromString("content full text"), 2);
List<GlobalIndexIOMeta> metas = toIOMetas(writer.finish(), indexPath);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Update the new tests for the current full-text metadata helper

mvn -pl paimon-full-text -am -Dtest=NativeFullTextGlobalIndexTest,NativeFullTextRowFilterTest -DfailIfNoTests=false test fails at testCompile after merging this head with master (2be2aed46d). Since #11248, toIOMetas takes only the result list and uses the path from each result. These three new calls still pass indexPath separately. Please rebase, switch all three new callers to the one-argument helper, and rerun the native tests.

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.

2 participants