Class: ContentEmbedding::ArticleEmbedding
- Inherits:
-
ContentEmbedding
- Object
- ContentEmbedding
- ContentEmbedding::ArticleEmbedding
- Includes:
- TextSearchable
- Defined in:
- app/models/content_embedding/article_embedding.rb
Overview
== Schema Information
Table name: content_embeddings_articles
Database name: primary
id :bigint not null, primary key
content_hash :string(32)
content_type :string default("primary"), not null
embeddable_type :string not null
embedding_dimensions :integer
embedding_model :string
locale :string default("en")
model :string
token_count :integer
unified_embedding :vector
created_at :timestamp not null
updated_at :timestamp not null
embeddable_id :bigint not null
Indexes
idx_content_embeddings_articles_embedding_model (embedding_model)
idx_content_embeddings_articles_unique (embeddable_id,content_type,locale) UNIQUE
Foreign Keys
fk_content_embeddings_articles_embeddable (embeddable_id => articles.id) ON DELETE => cascade
ContentEmbedding STI subclass for article embeddings.
Constant Summary
Constants included from TextSearchable
TextSearchable::SIMILARITY_THRESHOLD
Belongs to collapse
- #embeddable ⇒ Article (also: #article)
Class Method Summary collapse
-
.apply_published_filter(scope) ⇒ ActiveRecord::Relation
Filter to published articles only.
-
.primary_content ⇒ ActiveRecord::Relation<ContentEmbedding::ArticleEmbedding>
A relation of ContentEmbedding::ArticleEmbeddings that are primary content.
Methods included from TextSearchable
apply_locale_filter, generate_text_query_embedding, locale_filtered?, semantic_search
Class Method Details
.apply_published_filter(scope) ⇒ ActiveRecord::Relation
Filter to published articles only
51 52 53 54 55 |
# File 'app/models/content_embedding/article_embedding.rb', line 51 def apply_published_filter(scope) scope.joins('INNER JOIN articles ON articles.id = content_embeddings_articles.embeddable_id') .where(articles: { state: 'published' }) .merge(Article.knowledge_corpus) end |
.primary_content ⇒ ActiveRecord::Relation<ContentEmbedding::ArticleEmbedding>
A relation of ContentEmbedding::ArticleEmbeddings that are primary content. Active Record Scope
45 |
# File 'app/models/content_embedding/article_embedding.rb', line 45 scope :primary_content, -> { where(content_type: 'primary') } |
Instance Method Details
#embeddable ⇒ Article Also known as: article
40 |
# File 'app/models/content_embedding/article_embedding.rb', line 40 belongs_to :embeddable, class_name: 'Article' |