bbcarchdev / spindle

RES Linked Open Data aggregation engine
https://bbcarchdev.github.io/spindle/
Apache License 2.0
2 stars 1 forks source link

using "q" parameter along with media filters when searching within a collection gives 500 #62

Closed simeonvandersteen closed 8 years ago

simeonvandersteen commented 8 years ago

Logs show this:


LINE 1: ... dench') "query" LEFT JOIN "membership" "cm1" ON ("i"."id" =...
                                                             ^
HINT:  There is an entry for table "i", but it cannot be referenced from this part of the query.

index.fcgi: Critical: spindle: query execution failed
index.fcgi: Error: Status 500: The server encountered an unexpected condition while processing the request.```
nevali commented 8 years ago

This appears to be due to a mix of implicit and explicit joins in the actual query.

quilt: [Debug] spindle: SQL: SELECT "i"."id", "i"."classes", "i"."title", "i"."description", "i"."coordinates", "i"."modified", ts_rank_cd("i"."index_en_gb", "query", 32) AS "rank"
  FROM
    "index" "i", plainto_tsquery('judi dench') "query" 
  LEFT JOIN
    "membership" "cm1" ON ("i"."id" = "cm1"."id" AND "cm1"."collection" = '202260585b944a8bbac21769e07792b5') 
  WHERE
    "i"."score" <= 40 AND 
    "query" @@ "index_en_gb" AND
    "i"."id" IN ( 
      SELECT 
          "a"."about"
        FROM 
          "about" "a" 
        INNER JOIN
          "index_media" "im" ON ("a"."id" = "im"."id")
        INNER JOIN
          "media" "m" ON ("im"."media" = "m"."id")
        LEFT JOIN
          "membership" "cm2" ON ("im"."id" = "cm2"."id" AND "cm2"."collection" = '202260585b944a8bbac21769e07792b5')
       WHERE
         ("cm1"."collection" IS NOT NULL OR "cm2"."collection" IS NOT NULL)
  )
  ORDER BY "rank" DESC, "i"."score" ASC, "modified" DESC
  LIMIT 26