All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bigdata.rdf.sparql.ast.eval.bsbm.bi.query3.rq Maven / Gradle / Ivy

There is a newer version: 2.1.4
Show newest version
# BSBM BI Q3
#
# Query 3: Products with largest increase of interest (ratio of review counts) from one month to the next.
#
# Use Case Motivation: Some stakeholder wants to get a list of products with the highest increase in popularity in a certain period for further investigation.
#
# Last Changed Rev: 5682
# Last Changed Date: 2011-11-17 20:09:12 -0500 (Thu, 17 Nov 2011)
# solutions=10, chunks=1, elapsed=87239ms.
# solutions=10, chunks=1, elapsed=84904ms.
#
# This query begs for a RangeBOp to handle the constraint on the date range.
# Right now it winds up running these predicates once in each subquery and
# then filtering.  If we were going to run it that way we would be better 
# off extracting the common joins into a named subquery.
# 
#       ?review bsbm:reviewFor ?product .
#       ?review dc:date ?date .
	
  prefix bsbm: 
  prefix bsbm-inst: 
  prefix rev: 
  prefix dc: 
  prefix xsd: 
  Select ?product (xsd:float(?monthCount)/?monthBeforeCount As ?ratio)
  {
    { Select ?product (count(?review) As ?monthCount)
      {
        ?review bsbm:reviewFor ?product .
        ?review dc:date ?date .
        Filter(?date >= "2008-02-02"^^ && ?date < "2008-03-01"^^)
      }
      Group By ?product
    }  {
      Select ?product (count(?review) As ?monthBeforeCount)
      {
        ?review bsbm:reviewFor ?product .
        ?review dc:date ?date .
        Filter(?date >= "2008-01-05"^^ && ?date < "2008-02-02"^^) #
      }
      Group By ?product
      Having (count(?review)>0)
    }
  }
  Order By desc(xsd:float(?monthCount) / ?monthBeforeCount) ?product
  Limit 10




© 2015 - 2024 Weber Informatics LLC | Privacy Policy