schema

package
v0.263.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// FeedsIndex is the index containing [model.Feed] documents.
	FeedsIndex opensearch.Index = "feeds"
	// ItemsIndex is the index containing [models.Item] documents.
	ItemsIndex opensearch.Index = "items"
	// FavoritesIndex is the index containing [models.Article] that a user has favorited.
	FavoritesIndex opensearch.Index = "favorites"
	// UsersIndex is the index containing [model.User] documents.
	UsersIndex opensearch.Index = "users"
	// SubscriptionsIndex is the index containing [models.Subscription] documents.
	SubscriptionsIndex opensearch.Index = "subscriptions"
	// SchedulerIndex is the index containing data for scheduled jobs and job data.
	SchedulerIndex opensearch.Index = "scheduler"
	// SessionsIndex is the index containing user session data.
	SessionsIndex opensearch.Index = "sessions"
	// ImportsIndex is the index containing user import jobs data.
	ImportsIndex opensearch.Index = "imports"
)

Variables

ArticleFiltersMapping is a common mapping configuration for article filtering fields.

View Source
var CommonComponentTemplate = indices.NewComponentTemplateRequest("common",
	indices.WithIndexSettings(
		indices.WithMappings(CommonMappings),
		indices.WithAnalyzer(englishExactAnalyzer),
		indices.WithAnalyzer(personAnalyzer),
		indices.WithAnalyzer(htmlAnalyzer),
		indices.WithTokenizer(emailTokenizer),
		indices.WithNormalizer(lowercaseNormalizer),
	),
)

CommonComponentTemplate is a component template containing the common mappings.

View Source
var CommonMappings = indices.NewMappings(
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("published"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("updated"),
	indices.WithMapping("title",
		indices.WithTextMappingProperties(
			indices.WithMapping("exact",
				indices.WithTextMappingAnalyzer(englishExactAnalyzer),
			),
			indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
		),
	),
	indices.WithMapping("description", indices.WithTextMappingAnalyzer(htmlAnalyzer)),
	indices.WithMapping("authors",
		indices.WithTextMappingAnalyzer(personAnalyzer),
		indices.WithTextMappingProperties(
			indices.WithMapping("raw", indices.WithKeywordIgnoreAbove(256)),
			indices.WithMapping("exact",
				indices.WithTextMappingAnalyzer(englishExactAnalyzer),
			),
			indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
		),
	),
	indices.WithMapping("contributors",
		indices.WithTextMappingAnalyzer(personAnalyzer),
		indices.WithTextMappingProperties(
			indices.WithMapping("raw", indices.WithKeywordIgnoreAbove(256)),
			indices.WithMapping("exact",
				indices.WithTextMappingAnalyzer(englishExactAnalyzer),
			),
			indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
		),
	),
	indices.WithMapping("categories",
		indices.WithTextMappingProperties(
			indices.WithMapping("raw",
				indices.WithKeywordIgnoreAbove(256),
			),
			indices.WithMapping("raw_nocase",
				indices.WithKeywordMappingNormalizer(lowercaseNormalizer),
				indices.WithKeywordIgnoreAbove(256),
			),
			indices.WithMapping("exact",
				indices.WithTextMappingAnalyzer(englishExactAnalyzer),
			),
			indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
		),
	),
	indices.WithMapping("language", indices.WithKeywordIgnoreAbove(24)),
	indices.WithMapping[opensearchapi.CommonMappingTextProperty]("copyright"),
	indices.WithMapping("source_type", indices.WithKeywordIgnoreAbove(256)),
	indices.WithMapping("url", indices.WithKeywordIgnoreAbove(256)),
	ImageMapping,
)

CommonMappings are field mappings common across [models.Item] and [models.Feed].

FavoritesComponentTemplate is a component template containing FavoritesMappings.

FavoritesIndexTemplate is a index template for user favorites of [models.Item].

View Source
var FeedsComponentTemplate = indices.NewComponentTemplateRequest(FeedsIndex.String(),
	indices.WithIndexSettings(
		indices.WithMappings(FeedsMappings),
		indices.WithAnalyzer(englishExactAnalyzer),
		indices.WithAnalyzer(domainNameAnalyzer),
		indices.WithTokenizer(domainTokenizer),
		indices.WithAnalyzer(htmlAnalyzer),
		indices.WithTokenizer(emailTokenizer),
	),
)

FeedsComponentTemplate is a component template containing [FeedMappings].

FeedsIndexTemplate is a index template for [models.Feed].

View Source
var FeedsMappings = indices.NewMappings(
	indices.WithMapping("feed_id", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("created_at"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("last_fetched"),
	indices.WithMapping[opensearchapi.CommonMappingUnsignedLongNumberProperty]("update_interval"),
	indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("updates_disabled"),
	indices.WithMapping("source_urls", indices.WithKeywordIgnoreAbove(256)),
	indices.WithMapping("fetch_method", indices.WithKeywordIgnoreAbove(24)),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("fetch_options"),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("quirks"),
	indices.WithMapping("domain",
		indices.WithTextMappingAnalyzer(domainNameAnalyzer),
		indices.WithTextMappingProperties(
			indices.WithMapping("raw", indices.WithKeywordIgnoreAbove(256)),
			indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
		),
	),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("source_data"),
	indices.WithMapping("customisation",
		indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
		indices.WithObjectMappingProperties(
			indices.WithMapping("title",
				indices.WithTextMappingProperties(
					indices.WithMapping("exact",
						indices.WithTextMappingAnalyzer(englishExactAnalyzer),
					),
					indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
				),
			),
			indices.WithMapping("description", indices.WithTextMappingAnalyzer(htmlAnalyzer)),
		),
	),
)

ImageMapping is a common mapping configuration for an image.

ImportsComponentTemplate is a component template containing ImportsMappings.

ImportsIndexTemplate is a index template for [models.ImportStatus].

ItemsComponentTemplate is a component template containing [ItemMappings].

View Source
var ItemsISM = opensearchapi.ISMPolicy{
	ISMTemplate: new(opensearchapi.NewISMPolicyTemplateFromISMTemplate(
		opensearchapi.ISMTemplate{
			IndexPatterns: []string{ItemsIndex.String() + "-*"},
			Priority:      new(100.0),
		},
	)),
	States: []opensearchapi.ISMStates{
		{
			Name: new("hot"),
			Actions: []opensearchapi.ISMAction{
				{Rollover: &opensearchapi.ISMActionRollover{MinSize: new("10gb")}},
			},
			Transitions: []opensearchapi.ISMTransition{
				{StateName: new("merge")},
			},
		},
		{
			Name: new("merge"),
			Actions: []opensearchapi.ISMAction{
				{ForceMerge: &opensearchapi.ISMActionForceMerge{MaxNumSegments: new(1)}},
			},
		},
	},
}

ItemsIndexTemplate is a index template for [models.Item].

SchedulerComponentTemplate is a component template containing SchedulerMappings.

SchedulerIndexTemplate is a index template for [models.Feed].

SchedulerMappings is the field mappings for [models.Session].

SessionsComponentTemplate is a component template containing SchedulerMappings.

SessionsIndexTemplate is a index template for [models.Feed].

SessionsMappings is the field mappings for [models.Session].

View Source
var SubscriptionsComponentTemplate = indices.NewComponentTemplateRequest(SubscriptionsIndex.String(),
	indices.WithIndexSettings(
		indices.WithMappings(SubscriptionsMappings),
		indices.WithAnalyzer(englishExactAnalyzer),
		indices.WithAnalyzer(htmlAnalyzer),
		indices.WithTokenizer(emailTokenizer),
	),
)

SubscriptionsComponentTemplate is a component template containing SubscriptionsMappings.

SubscriptionsIndexTemplate is a index template for [models.Subscription].

View Source
var SubscriptionsMappings = indices.NewMappings(
	indices.WithMapping("subscription_id", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping("user_id", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping("type", indices.WithKeywordIgnoreAbove(24)),
	indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("favorite"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("created_at"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("updated_at"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("marked_read_at"),
	indices.WithMapping("customisation",
		indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
		indices.WithObjectMappingProperties(
			indices.WithMapping("nickname",
				indices.WithTextMappingProperties(
					indices.WithMapping("exact",
						indices.WithTextMappingAnalyzer(englishExactAnalyzer),
					),
					indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
				),
			),
			indices.WithMapping("categories",
				indices.WithTextMappingProperties(
					indices.WithMapping("exact",
						indices.WithTextMappingAnalyzer(englishExactAnalyzer),
					),
					indices.WithMapping[opensearchapi.CommonMappingSearchAsYouTypeProperty]("search"),
				),
			),
			indices.WithMapping("image_url", indices.WithKeywordIgnoreAbove(256)),
		),
	),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("settings"),
	indices.WithMapping("feed_data",
		indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
		indices.WithObjectMappingProperties(
			indices.WithMapping("feed_id", indices.WithKeywordIgnoreAbove(32)),
			indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("article_states"),
			ArticleFiltersMapping,
		),
	),
	indices.WithMapping("group_data",
		indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
		indices.WithObjectMappingProperties(
			indices.WithMapping("subscriptions", indices.WithKeywordIgnoreAbove(32)),
			indices.WithMapping("metadata",
				indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
				indices.WithObjectMappingProperties(
					indices.WithMapping("feed_id", indices.WithKeywordIgnoreAbove(32)),
					indices.WithMapping("subscription_id", indices.WithKeywordIgnoreAbove(32)),
				),
			),
			ArticleFiltersMapping,
		),
	),
	indices.WithMapping("email_data",
		indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
		indices.WithObjectMappingProperties(
			indices.WithMapping("feed_id", indices.WithKeywordIgnoreAbove(32)),
			indices.WithMapping("email_sender_id", indices.WithKeywordIgnoreAbove(256)),
			indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("article_states"),
			ArticleFiltersMapping,
		),
	),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("search_data"),
)

UsersComponentTemplate is a component template containing UsersMappings.

UsersIndexTemplate is a index template for [models.User].

View Source
var UsersMappings = indices.NewMappings(
	indices.WithMapping("user_id", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping("nickname", indices.WithKeywordIgnoreAbove(128)),
	indices.WithMapping("avatar_url", indices.WithKeywordIgnoreAbove(256)),
	indices.WithMapping("external_user_id", indices.WithKeywordIgnoreAbove(64)),
	indices.WithMapping("email", indices.WithKeywordIgnoreAbove(128)),
	indices.WithMapping("provider", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping("level", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("created_at"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("updated_at"),
	indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("last_login"),
	indices.WithMapping[opensearchapi.CommonMappingUnsignedLongNumberProperty]("login_count"),
	indices.WithMapping("max_history", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("settings"),
	indices.WithMapping("subscription_type", indices.WithKeywordIgnoreAbove(32)),
	indices.WithMapping[opensearchapi.CommonMappingFlatObjectProperty]("subscription"),
	indices.WithMapping("customisation",
		indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
		indices.WithObjectMappingProperties(
			indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("blocked"),
			indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("email_verified"),
			indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("policies_accepted"),
			indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("pending_deletion"),
			indices.WithMapping("susbcription_limit",
				indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
				indices.WithObjectMappingProperties(
					indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("exceeded"),
					indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("timestamp"),
				),
			),
			indices.WithMapping("newsletter_limit",
				indices.WithObjectMappingDynamic(opensearchapi.NewCommonMappingDynamicFromBool(false)),
				indices.WithObjectMappingProperties(
					indices.WithMapping[opensearchapi.CommonMappingBooleanProperty]("exceeded"),
					indices.WithMapping[opensearchapi.CommonMappingDateNanosProperty]("timestamp"),
				),
			),
		),
	),
	indices.WithMapping("item_favorites", indices.WithKeywordIgnoreAbove(32)),
)

UsersMappings is the field mappings for [models.User].

Functions

func ItemsIngestPipeline added in v0.260.0

func ItemsIngestPipeline(modelID string) opensearchapi.IngestPutPipelineReq

ItemsIngestPipeline defines an ingest pipeline for processing [models.Item] before indexing.

Types

type IndexConfig added in v0.261.0

type IndexConfig struct {

	// Name is the canonical name of the index.
	Name string
	// IndexTemplate is an index template for the index.
	IndexTemplate opensearchapi.IndicesPutIndexTemplateReq
	// ComponentTemplate is a component template for the index.
	ComponentTemplate opensearchapi.ClusterPutComponentTemplateReq
	// ReadAlias is the read-only index alias.
	ReadAlias string
	// WriteAlias is the read-write index alias.
	WriteAlias string
	// contains filtered or unexported fields
}

func NewIndexConfig added in v0.261.0

func NewIndexConfig(osc *opensearch.Client, index opensearch.Index) (IndexConfig, error)

NewIndexConfig generates an IndexConfig for the given opensearch.Index. This includes the appropriate canonical index name, index/component templates and read/write aliases for the index.

func (*IndexConfig) InitIndex added in v0.261.0

func (c *IndexConfig) InitIndex(ctx context.Context, osc *opensearch.Client) error

InitIndex will ensure all index templates and aliases exist and creates a new index ready for use.

func (*IndexConfig) UpdateAlias added in v0.261.0

func (c *IndexConfig) UpdateAlias(ctx context.Context, osc *opensearch.Client, aliasType string) error

UpdateAlias will update the read/write aliases for an index.

func (*IndexConfig) UpdateIndex added in v0.261.0

func (c *IndexConfig) UpdateIndex(ctx context.Context, osc *opensearch.Client) error

UpdateIndex will update all templates for an index.

func (*IndexConfig) UpdateTemplates added in v0.261.0

func (c *IndexConfig) UpdateTemplates(ctx context.Context, osc *opensearch.Client) error

UpdateTemplates will update the index and component templates for an index, and performs any index-specific configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL