Skip to content

Latest commit

 

History

History
78 lines (67 loc) · 3.18 KB

5.md

File metadata and controls

78 lines (67 loc) · 3.18 KB

Find products matching two different sets of features

Description

After looking at information about some products, the consumer has a more specific idea what he wants. Therefore, he asks for products matching either one set of features or another set.

The complexity in this case is the union of the sets of products selected by two different patterns. The corresponding query defines a product type, randomly selected from the product types class hierarchy at the leaf level, three different randomly selected product features and two random numbers between 1 and 500. Both patterns look for the first feature, combined with the second one and the first random number in the case of the first pattern. The second patterns also looks for the first feature but combined with the third and the second random number.

Sample

"Look for products of type sheeny with product features stroboscopes and gadgeteers and a productPropertyNumeric1 value greater than 300 plus those of the same product type with product features stroboscopes and rotifers and a productPropertyNumeric2 greater than 400".

Expected Outcome

Given the sample dataset bsbm-1000products, the product labels the user should obtain if restricted to the first 5 ordered alphabetically are:

"auditoriums reducing pappies", "boozed", "driveled", "elatedly fidelis release", "zellations".

SPARQL Query to Perform

SELECT DISTINCT ?product ?label ?propertyTextual
WHERE {
   {
	?product rdfs:label ?label .
	?product rdf:type %ProductType% .
	?product bsbm:productFeature %ProductFeature1% .
	?product bsbm:productFeature %ProductFeature2% .
	?product bsbm:productPropertyTextual1 ?propertyTextual .
	?product bsbm:productPropertyNumeric1 ?p1 .
	FILTER ( ?p1 > %x% )
   } UNION {
	?product rdfs:label ?label .
	?product rdf:type %ProductType% .
	?product bsbm:productFeature %ProductFeature1% .
	?product bsbm:productFeature %ProductFeature3% .
	?product bsbm:productPropertyTextual1 ?propertyTextual .
	?product bsbm:productPropertyNumeric2 ?p2 .
	FILTER ( ?p2 > %y% )
   }
}
ORDER BY ?label
LIMIT 5

SPARQL Query for the Sample Query

PREFIX bsbm: <http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/vocabulary/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?product ?label ?propertyTextual
WHERE {
	{
	?product rdfs:label ?label .
	?product a/rdfs:subClassOf? ?sheenyType .
	?sheenyType rdfs:label "sheeny" .
	?product bsbm:productFeature ?stroboscopes .
	?stroboscopes rdfs:label "stroboscopes" .
	?product bsbm:productFeature ?gadgeteers .
	?gadgeteers rdfs:label "gadgeteers" .
	?product bsbm:productPropertyTextual1 ?propertyTextual .
	?product bsbm:productPropertyNumeric1 ?p1 .
	FILTER ( ?p1 > 300 )
	} UNION {
	?product rdfs:label ?label .
	?product a/rdfs:subClassOf? ?sheenyType .
	?sheenyType rdfs:label "sheeny" .
	?product bsbm:productFeature ?stroboscopes .
	?stroboscopes rdfs:label "stroboscopes" .
	?product bsbm:productFeature ?rotifers .
	?rotifers rdfs:label "rotifers" .
	?product bsbm:productPropertyTextual1 ?propertyTextual .
	?product bsbm:productPropertyNumeric2 ?p2 .
	FILTER (?p2 > 400 )
	}
}
ORDER BY ?label
LIMIT 5