Skip to content

Weights on associations #529

@trevorfoxsoft

Description

@trevorfoxsoft

I am using search scopes and want to apply weights to associations. I have seen #132 and #40 but the syntax presented in them doesn’t seem to work.

  pg_search_scope :full_search,
                  against: {
                    title: "A",
                    introduction: "B",
                    hashtag: "C"
                  },
                  associated_against: {
                    content_rows: [
                      { text_1: "D" },
                      { text_2: "E" },
                      { image_caption_1: "F" },
                      { image_caption_2: "G" }
                    ]
                  }

Gives the error PG::UndefinedColumn: ERROR: column content_rows.{:text_1=>"D"} does not exist LINE 1: ...IN (SELECT "content_pages"."id" AS id, string_agg("content_r... ^

And

  pg_search_scope :full_search,
                  against: {
                    title: "A",
                    introduction: "B",
                    hashtag: "C"
                  },
                  associated_against: {
                    content_rows: {
                      text_1: "D",
                      text_2: "E",
                      image_caption_1: "F",
                      image_caption_2: "G"
                    }
                  }

gives PG::InternalError: ERROR: unrecognized weight: 69 .

Is there a way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions