Skip to content
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

Added Index-Based Configurable Partial Search Result Setting #4

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Roaster05
Copy link
Owner

@Roaster05 Roaster05 commented Jun 13, 2024

This PR introduces an index-based configurable setting for partial search results in Elasticsearch. The primary objective is to enable a boolean variable (isPartialSearchAllowed) at the index level, which dictates whether partial search results are allowed for queries involving multiple indices.

Key Changes

1. New Index Metadata Field

  • Index Metadata Enhancement: Added a new boolean field partial_search_allowed to the index metadata. This field is dynamically set based on a cluster-wide setting and can be updated independently for each index.

2. Index Setting Update

  • Dynamic Setting: Implemented a new index based setting, indices.partial_search.total.use_index_based_setting, to control the index-based partial search behavior.
    • Default value: false
    • This setting is dynamic and scoped to the index triggered.

3. Index Metadata Builders

  • Metadata Builders: Introduced builders (IndexMetadata.Builder) to construct and update index metadata with the partial_search_allowed field.
    • Builders facilitate the creation of updated index metadata instances reflecting changes in the partial_search_allowed setting.

4. Python Automation Script

  • Automated Index Update Script: Developed a Python script (AutomatedIndexUpdateScript.py) that periodically checks indices based on their creation date.
    • If an index's age exceeds a specified threshold (e.g., 5 minutes), the script sets partial_search_allowed to true, utilizing Elasticsearch's Python client (elasticsearch-py).

5. Integration with Search Request Handling

  • Search Request Handling: Integrated logic (TransportSearchAction.java) to evaluate the partial_search_allowed flag for each index involved in a search request.
    • Determines whether to allow partial search results based on the collective state of partial_search_allowed flags across indices in the search request.

Configuration for Index-Based Partial Search Setting

To configure the index.partial_search_allowed setting for a specific index, use the following configuration in Kibana or through the Elasticsearch API:

Enable Partial Search for a Specific Index

Replace {index_name} with the name of your index.

PUT /{index_name}/_settings
{
  "index": {
    "partial_search_allowed": true
  }
}

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