Skip to content

Add stats tracking for semantic field #1362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 9, 2025

Conversation

bzhangam
Copy link
Collaborator

@bzhangam bzhangam commented Jun 2, 2025

Description

Add stats tracking for semantic field

Below is an example response for create, index and query semantic field with sparse model.

{
	"_nodes": {
		"total": 1,
		"successful": 1,
		"failed": 0
	},
	"cluster_name": "integTest",
	"info": {
		"cluster_version": "3.1.0",
		"processors": {
			"search": {
				"hybrid": {
					"comb_geometric_processors": 0,
					"comb_rrf_processors": 0,
					"norm_l2_processors": 0,
					"norm_minmax_processors": 0,
					"comb_harmonic_processors": 0,
					"comb_arithmetic_processors": 0,
					"norm_zscore_processors": 0,
					"rank_based_normalization_processors": 0,
					"normalization_processors": 0
				}
			},
			"ingest": {
				"text_chunking_delimiter_processors": 0,
				"text_embedding_processors_in_pipelines": 0,
				"text_chunking_fixed_length_processors": 0,
				"text_embedding_skip_existing_processors": 0,
				"text_chunking_processors": 0
			}
		}
	},
	"all_nodes": {
		"query": {
			"hybrid": {
				"hybrid_query_with_pagination_requests": 0,
				"hybrid_query_with_filter_requests": 0,
				"hybrid_query_with_inner_hits_requests": 0,
				"hybrid_query_requests": 0
			},
			"neural": {
				"neural_query_against_semantic_sparse_requests": 1,
				"neural_query_requests": 1,
				"neural_query_against_semantic_dense_requests": 0,
				"neural_query_against_knn_requests": 0
			},
			"neural_sparse": {
				"neural_sparse_query_requests": 0
			}
		},
		"semantic_highlighting": {
			"semantic_highlighting_request_count": 0
		},
		"processors": {
			"search": {
				"hybrid": {
					"comb_harmonic_executions": 0,
					"norm_zscore_executions": 0,
					"comb_rrf_executions": 0,
					"norm_l2_executions": 0,
					"rank_based_normalization_processor_executions": 0,
					"comb_arithmetic_executions": 0,
					"normalization_processor_executions": 0,
					"comb_geometric_executions": 0,
					"norm_minmax_executions": 0
				}
			},
			"ingest": {
				"text_chunking_executions": 0,
				"text_embedding_executions": 0,
				"semantic_field_executions": 1,
				"semantic_field_chunking_executions": 1,
				"text_embedding_skip_existing_executions": 0,
				"text_chunking_fixed_length_executions": 0,
				"text_chunking_delimiter_executions": 0
			}
		}
	},
	"nodes": {
		"j6A0rlYBR7mK1R_k178qdg": {
			"query": {
				"hybrid": {
					"hybrid_query_with_pagination_requests": 0,
					"hybrid_query_with_filter_requests": 0,
					"hybrid_query_with_inner_hits_requests": 0,
					"hybrid_query_requests": 0
				},
				"neural": {
					"neural_query_against_semantic_sparse_requests": 1,
					"neural_query_requests": 1,
					"neural_query_against_semantic_dense_requests": 0,
					"neural_query_against_knn_requests": 0
				},
				"neural_sparse": {
					"neural_sparse_query_requests": 0
				}
			},
			"semantic_highlighting": {
				"semantic_highlighting_request_count": 0
			},
			"processors": {
				"search": {
					"hybrid": {
						"comb_harmonic_executions": 0,
						"norm_zscore_executions": 0,
						"comb_rrf_executions": 0,
						"norm_l2_executions": 0,
						"rank_based_normalization_processor_executions": 0,
						"comb_arithmetic_executions": 0,
						"normalization_processor_executions": 0,
						"comb_geometric_executions": 0,
						"norm_minmax_executions": 0
					}
				},
				"ingest": {
					"text_chunking_executions": 0,
					"text_embedding_executions": 0,
					"semantic_field_executions": 1,
					"semantic_field_chunking_executions": 1,
					"text_embedding_skip_existing_executions": 0,
					"text_chunking_fixed_length_executions": 0,
					"text_chunking_delimiter_executions": 0
				}
			}
		}
	}
}

Related Issues

N/A

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@q-andy
Copy link
Contributor

q-andy commented Jun 2, 2025

Could you include an example of the new API response in the PR description?

@bzhangam bzhangam force-pushed the main branch 2 times, most recently from f491352 to 5eade10 Compare June 4, 2025 17:41
@q-andy
Copy link
Contributor

q-andy commented Jun 4, 2025

Could you update the neural query integ tests to verify the stats are only incremented once for each query type?

@bzhangam
Copy link
Collaborator Author

bzhangam commented Jun 4, 2025

Could you update the neural query integ tests to verify the stats are only incremented once for each query type?

Currently we cannot run integ tests for the semantic field related use cases. I think we can address in a separate PR where we add the integ tests for semantic fields.

@q-andy
Copy link
Contributor

q-andy commented Jun 4, 2025

Could you update the neural query integ tests to verify the stats are only incremented once for each query type?

Currently we cannot run integ tests for the semantic field related use cases. I think we can address in a separate PR where we add the integ tests for semantic fields.

For neural query request count against sparse/dense, don't those stats work without semantic field?

@bzhangam bzhangam force-pushed the main branch 3 times, most recently from 12579dd to abbb5e2 Compare June 4, 2025 20:24
@bzhangam
Copy link
Collaborator Author

bzhangam commented Jun 4, 2025

Could you update the neural query integ tests to verify the stats are only incremented once for each query type?

Currently we cannot run integ tests for the semantic field related use cases. I think we can address in a separate PR where we add the integ tests for semantic fields.

For neural query request count against sparse/dense, don't those stats work without semantic field?

ok added

Comment on lines 103 to +105
public void testQueryWithBoostAndImageQueryAndRadialQuery() {
// Enable stats for the test
updateClusterSettings(NEURAL_STATS_ENABLED.getKey(), true);
Copy link
Contributor

@q-andy q-andy Jun 4, 2025

Choose a reason for hiding this comment

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

Could we have this a separate testQueryWithBoostAndImageQueryAndRadialQuery_statsEnabled() test? Following the pattern of the other stats ITs. So we can validate both stats disabled and stats enabled happy case. Same with the neural sparse test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's not necessary to test stats disabled everywhere. One test to cover that should already be good enough since the disable logic is not related to this PR.

@@ -173,7 +176,10 @@ private void process(
) {
setModelInfo(ingestDocument, semanticFieldInfoList);

chunk(ingestDocument, semanticFieldInfoList);
boolean shouldRecordChunking = chunk(ingestDocument, semanticFieldInfoList);
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] chunk method simply returns whether the chunk is enabled or disabled. The variable name should reflect this behavior only in my opinion.

boolean chunked = chunk(ingestDocument, semanticFieldInfoList);
if (chunked) {
    EventStatsManager.increment(EventStatName.SEMANTIC_FIELD_PROCESSOR_CHUNKING_EXECUTIONS);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok

@heemin32 heemin32 merged commit fe29ec5 into opensearch-project:main Jun 9, 2025
51 of 53 checks passed
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (a6669e4) to head (301d6b5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #1362       +/-   ##
============================================
- Coverage     82.47%       0   -82.48%     
============================================
  Files           149       0      -149     
  Lines          7531       0     -7531     
  Branches       1211       0     -1211     
============================================
- Hits           6211       0     -6211     
+ Misses          859       0      -859     
+ Partials        461       0      -461     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

5 participants