Where should I configure max_result_window index setting?
Asked Answered
H

2

22

I'm trying to add to my elasticsearch.yml

index.max_result_window: 10000

But the problem is it doesn't like me adding index. in the configuration (it results in an error), this was working in elastica version 2.X, but now in 6.X it doesn't seem to work. Any idea how to configure indexes in recent elastica versions? I can't seem to find an answer to this.

Hanson answered 9/4, 2019 at 13:45 Comment(0)
C
31

The max_result_window is a dynamic index level setting, not node specific. The default is 10,000, so if that's the value you'd like to set, there should be no need.

You can adjust it by updating either a specific index settings or globally across all existing indices:

PUT _settings
{
  "index.max_result_window": 11000
}

The above would update all existing indices. To have it take effect on future indices, you'd need an index template that targets specific index patterns (or just * for global) - as an example:

PUT _template/example
{
  "index_patterns": ["settings_test*"],
  "settings": {
    "index.max_result_window": 12000
  }
}

PUT settings_test

The above would yield the following:

GET settings_test
...

{
  "settings_test" : {
    "aliases" : { },
    "mappings" : { },
    "settings" : {
      "index" : {
        ...
        "max_result_window" : "12000",
        ...
      }
    }
  }
}

Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html

Chive answered 9/4, 2019 at 16:3 Comment(2)
Thanks for your response but per my tag I'm looking for an elastica solution.Hanson
Elastica is just a client for accessing the Elasticsearch cluster - you indicated you were trying to update your elasticsearch.yml file which has nothing to do with Elastica. The commands above can be done either as simple curl commands against the Elasticsearch cluster, or if you want to use Elastica, look at the setSettings method which will send the same info above to your Elasticsearch cluster. Ref: elastica.io/api/latest/classes/…Chive
N
0

For elastica I think this is the solution:

// Load index
$elasticaIndex = $elasticaClient->getIndex('twitter');

// Create the index new
$elasticaIndex->create(
    array(
        'number_of_shards' => 4,
        'number_of_replicas' => 1,
        'analysis' => array(
            'analyzer' => array(
                'default_index' => array(
                    'type' => 'custom',
                    'tokenizer' => 'standard',
                    'filter' => array('lowercase', 'mySnowball')
                ),
                'default_search' => array(
                    'type' => 'custom',
                    'tokenizer' => 'standard',
                    'filter' => array('standard', 'lowercase', 'mySnowball')
                )
            ),
            'filter' => array(
                'mySnowball' => array(
                    'type' => 'snowball',
                    'language' => 'German'
                )
            )
        ),
        'max_result_window' => 10000
    ),
    true
);
Nervy answered 2/10, 2019 at 10:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.