ash json api filters

question-filter-q_explanation{
contains [...]
eq [...]
greater_than [...]
greater_than_or_equal [...]
ilike [...]
in [...]
is_nil [...]
less_than [...]
less_than_or_equal [...]
like [...]
not_eq [...]
}
question-filter-q_explanation{
contains [...]
eq [...]
greater_than [...]
greater_than_or_equal [...]
ilike [...]
in [...]
is_nil [...]
less_than [...]
less_than_or_equal [...]
like [...]
not_eq [...]
}
on swagger ui page, I see this king of spec. so, in the filter I can use q_explanation="some_string"&year=2011 How do I input > or < when writing nested filters for this? Claude has been really unhelpful at this.
10 Replies
abeeshake456
abeeshake456OP5mo ago
or ilike query.
ZachDaniel
ZachDaniel5mo ago
filter[explanation][ilike]="some-text"
abeeshake456
abeeshake456OP5mo ago
the expression is correct, however it does not work as expected. The ilike is actually not executed.
Parameters: %{"filter" => %{"q_explanation" => %{"ilike" => "\"Commission\""}, "year" => %{"greater_than" => "2011", "less_than" => "2020"}}}
Pipelines: [:api]


[debug] QUERY OK source="common_questions" db=8.3ms idle=1098.3ms
SELECT c0."id", c0."title", c0."year", c0."q_text", c0."q_image", c0."q_correct_answer", c0."q_explanation", c0."q_choices", c0."topics", c0."set_number", c0."verified_answer", c0."updated_at", c0."created_at", c0."q_source", c0."misc_sources_links", c0."topic_extraction_reasoning", c0."is_current", c0."is_static_oriented", c0."is_disputed_question", c0."is_controversial", c0."distractor_ratings", c0."external_knowledge_facts", c0."explanation_images", c0."q_reformatted_confidence_score", c0."q_reformatted_text" FROM "common_questions" AS c0 WHERE (c0."year"::bigint::bigint > $1::bigint::bigint) AND (c0."year"::bigint::bigint < $2::bigint::bigint) AND

(c0."q_explanation"::text ILIKE $3::varchar) [2011, 2020, "\"Commission\""]
<<<<< this seems to have formed correctly. >>>>>
Parameters: %{"filter" => %{"q_explanation" => %{"ilike" => "\"Commission\""}, "year" => %{"greater_than" => "2011", "less_than" => "2020"}}}
Pipelines: [:api]


[debug] QUERY OK source="common_questions" db=8.3ms idle=1098.3ms
SELECT c0."id", c0."title", c0."year", c0."q_text", c0."q_image", c0."q_correct_answer", c0."q_explanation", c0."q_choices", c0."topics", c0."set_number", c0."verified_answer", c0."updated_at", c0."created_at", c0."q_source", c0."misc_sources_links", c0."topic_extraction_reasoning", c0."is_current", c0."is_static_oriented", c0."is_disputed_question", c0."is_controversial", c0."distractor_ratings", c0."external_knowledge_facts", c0."explanation_images", c0."q_reformatted_confidence_score", c0."q_reformatted_text" FROM "common_questions" AS c0 WHERE (c0."year"::bigint::bigint > $1::bigint::bigint) AND (c0."year"::bigint::bigint < $2::bigint::bigint) AND

(c0."q_explanation"::text ILIKE $3::varchar) [2011, 2020, "\"Commission\""]
<<<<< this seems to have formed correctly. >>>>>
filter[q_explanation][contains] works ! (c0."q_explanation"::text LIKE $3) [2011, 2020, "%Commission%"] I think there is a bug in ilike implementation
ZachDaniel
ZachDaniel5mo ago
🤔 Whats the bug? You included encoded quotes in your filter, did you mean to do that?
abeeshake456
abeeshake456OP5mo ago
When I don't include quotes, then
[debug] Processing with AshTableVueWeb.AshJsonApiRouter
Parameters: %{"filter" => %{"q_explanation" => %{"ilike" => "Commission"}, "year" => %{"greater_than" => "2011", "less_than" => "2020"}}}
[debug] Processing with AshTableVueWeb.AshJsonApiRouter
Parameters: %{"filter" => %{"q_explanation" => %{"ilike" => "Commission"}, "year" => %{"greater_than" => "2011", "less_than" => "2020"}}}
and the SQL it runs is
debug] QUERY OK source="common_questions" db=7.6ms idle=1149.0ms
SELECT c0."id", c0."title", c0."year", c0."q_text", c0."q_image", c0."q_correct_answer", c0."q_explanation", c0."q_choices", c0."topics", c0."set_number", c0."verified_answer", c0."updated_at", c0."created_at", c0."q_source", c0."misc_sources_links", c0."topic_extraction_reasoning", c0."is_current", c0."is_static_oriented", c0."is_disputed_question", c0."is_controversial", c0."distractor_ratings", c0."external_knowledge_facts", c0."explanation_images", c0."q_reformatted_confidence_score", c0."q_reformatted_text" FROM "common_questions" AS c0 WHERE (c0."year"::bigint::bigint > $1::bigint::bigint) AND (c0."year"::bigint::bigint < $2::bigint::bigint) AND


(c0."q_explanation"::text ILIKE $3::varchar) [2011, 2020, "Commission"]
debug] QUERY OK source="common_questions" db=7.6ms idle=1149.0ms
SELECT c0."id", c0."title", c0."year", c0."q_text", c0."q_image", c0."q_correct_answer", c0."q_explanation", c0."q_choices", c0."topics", c0."set_number", c0."verified_answer", c0."updated_at", c0."created_at", c0."q_source", c0."misc_sources_links", c0."topic_extraction_reasoning", c0."is_current", c0."is_static_oriented", c0."is_disputed_question", c0."is_controversial", c0."distractor_ratings", c0."external_knowledge_facts", c0."explanation_images", c0."q_reformatted_confidence_score", c0."q_reformatted_text" FROM "common_questions" AS c0 WHERE (c0."year"::bigint::bigint > $1::bigint::bigint) AND (c0."year"::bigint::bigint < $2::bigint::bigint) AND


(c0."q_explanation"::text ILIKE $3::varchar) [2011, 2020, "Commission"]
there is no %Commission%
ZachDaniel
ZachDaniel5mo ago
🤔 Its not assuming that you want % around the text you send that from the client
abeeshake456
abeeshake456OP5mo ago
I see. it assumes that in filter[q_explanation][contains] :p
ZachDaniel
ZachDaniel5mo ago
No, those are just different functions contains means "does this string appear in the other string" ilike means "does this string match the provided pattern"
abeeshake456
abeeshake456OP5mo ago
this works. Will read it that way. Thanks a lot for removing the confusion.
ZachDaniel
ZachDaniel5mo ago
🙇‍♂️

Did you find this page helpful?