question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow index settings in Meta.index

See original GitHub issue

Currently, when defining a new DocType you have to create a separate Index object if you wish to configure any index-level settings. With the deprecation of multiple types in elasticsearch 6.0 it might make more sense to just allow the index settings to configurable on the DocType itself in some fashion.

This would then allow even for situations where given DocType is present in multiple indices (time-based indices for example) meaning its Meta.index would specify a wildcard (products-* for example) and provide settings which would then allow it to generate and save an IndeTemplate and/or create any particular index via the init classmethod.

Any ideas and feedback is more than welcome!

Inspired by @3lnc’s comment: https://github.com/elastic/elasticsearch-dsl-py/issues/779#issuecomment-350047587

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
honzakralcommented, Jan 6, 2018

I absolutely agree that Index/DocType distinction is no longer useful. What if we changed things around a bit, just brainstorming here so not all might make it to the target design or even make sense:

  • rename DocType to Document
  • remove all index-related options from Meta and ._doc_type
    • including init and index name
  • add class Index: as an (optional) section to Document that can contain definitions for:
    • index name (can contain a wildcard)
    • index settings/analyzers
    • method do determine index name for a document (like looking at a timestamp for example to go from my-idx-* to my-idx-2018.01.01)
    • template_name if this definition if to be defined via a template
    • rollover settings
    • alias setting allowing for some rules to
  • use those definitions to construct an Index object that will be accessible on the Document class (.index ??) which will:
    • store all the settings provided in the Index class
    • provide mechanisms for index management - create/create_template/delete/switch_alias (by default point an alias to latest index in the group)/rollover/shrink/allocation/…
    • have helper methods like migrate which will create a new index, reindex data from another index and swap alias

If someone wants to have multiple Document classes stored in a single index, the recommended way would be to use inheritance and override Meta.matches to dynamically determine which class to use for every hit returned. Question is how to then make sure the mappings get merged - I like the idea of a Document class iterating through all its subclasses and collecting mappings but it might be too confusing and dangerous so maybe we just do it explicitly somehow?

What do you think?

1reaction
honzakralcommented, May 24, 2018

#840 is ready for review and contains some examples showcasing some of the techniques made possible by this change

Read more comments on GitHub >

github_iconTop Results From Across the Web

Robots Meta Tags Specifications | Google Search Central
Learn how to add robots meta tags and read how page and text-level settings can be used to adjust how Google presents your...
Read more >
Update index settings API | Elasticsearch Guide [8.5] | Elastic
The list of per-index settings which can be updated dynamically on live indices can be found in Index modules. To preserve existing settings...
Read more >
Robots Meta Settings – Default (noindex) - WordPress.org
When zero posts are assigned, then TSF sets the default to “noindex.” You can overwrite this behavior by selecting “index” for the category....
Read more >
Working with Custom Meta keys and Indexes - YouTube
Adding new meta keys to Netwitness, adjusting Index Levels.
Read more >
The meta robots advanced settings in Yoast SEO
The advanced meta robots settings allow you to set the meta robots for this page or post to: no image index, which means...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found