Weights on associations
trevorfoxsoft opened this issue · comments
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?
Also just tried this syntax, which gives me the same unrecognized weight
error
pg_search_scope :full_search,
against: [
[ "title", "A" ],
[ "introduction", "B" ],
[ "hashtag", "E" ]
],
associated_against: {
content_rows: [
[ "text_1", "C" ],
[ "text_2", "D" ],
[ "image_caption_1", "F" ],
[ "image_caption_2", "G" ]
]
},
the second syntax is correct, but the error is because 'E' isn't a supported weight by postgres.setweight
only goes up to 'D'. https://www.postgresql.org/docs/current/textsearch-controls.html
Aah excellent, thanks. I'll forward this on to someone still working on the project it was relevant to as I never did get it fixed.