I have the following sample KB:
(:Ethan, :rel1, :Peter)
(:Ethan, :rel2, :son)
(:Sienna, :rel3, :Josie)
(:Sienna, :rel4, :daughter)
(:Josie, :rel5, :Peter)
(:Josie, :rel6, :wife)
Now I need to find a property path (all related triples) from :son to :wife. What would be the SPARQL query for that?
The result should be like this:
(:Ethan, :rel2, :son)
(:Ethan, :rel1, :Peter)
(:Josie, :rel5, :Peter)
(:Josie, :rel6, :wife)
Related
I am trying to query a specific RDF file. I need this solution for my work.
The file I have to work with is:
https://github.com/iliriani/Test/blob/main/Notebook.rdf
I am trying to get somehow all the attributes ( <attribute'>...<'name> ) of a given class( <class'>...<name'> ) within this model. But cannot find the right query!
For instance, I want to get all attributes of class "Teacher", it should return me:
id
Emri
Mbiemri
Lendet
Evaluations
User
Hope for your support.
I want to exclude child nodes path from search path using querybuilder
for example - parent folder is /content/mysite/en
and subfolders are
/content/mysite/en/testfolder1
/content/mysite/en/testfolder2
I want query builder to write a query to exclude these paths
I already looked at this question -
AEM Query builder exclude a folder in search
but grouping paths and p.not=true doesn't seem to be working as expected
I know it's a bit tricky to write such a query using query builder ; so I am using JCR/SQL2 query -
using
SELECT * FROM [cq:Page]
WHERE ISDESCENDANTNODE(page,'/content/mysite/en')
AND CONTAINS(*, 'fulltext')
AND NOT ISDESCENDANTNODE(page, '/content/mysite/en/testfolder1')
AND NOT ISDESCENDANTNODE(page, '/content/mysite/en/testfolder2')
but the issue now is that We also want the search excerpt which is created automatically by querybuilder api's SearchResult's hit object -
hit.getExcerpt()
so is there a way I can get the excerpt using JCR/SQL2 query ?
OR is there a way I can build the exclude subfolder query using querybuilder; so that I can get excerpts from results? Both solutions will solve my case.
If anyone has experience in excluding subfolder query using querybuilder; or building search excerpt using JCR/SQL2 query; or any other idea/suggestion for this case; help will be much appreciated
Try path.exact=true Below is a example
without path.exact=true
type=cq:Page
path=/content/wkndmuzik/us/en
output:
With path.exact=true
type=cq:Page
path=/content/wkndmuzik/us/en
path.exact=true
Output:
path.exact=true : If true exact path is matched, if false all descendants are included.
For other predicates on querybuider api visit the blog of Hashim Khan
Using Postman, I am forming a GET request query to my P21 database middleware to retrieve items with a specific value in a UserDefinedField.
I am able to query things on the top level of the item data, such as ItemID and ItemDesc like so:
http://[server]:[port]/api/inventory/parts?$query=ItemDesc eq 'CONTROL VALVE'
However, the values I would like to use in my query string are nested inside the UserDefinedFeilds element. I am specifically looking for items with:
http://[server]:[port]/api/inventory/parts?$query=UserDefinedFeilds/OnEbay eq 'Y'
But this is not the correct way to form this query string. Can anyone please explain how to specify a nested element inside a query string like this? Thanks.
In this situation, using P21 API, it is unnecessary to specify the parent field 'UserDefinedFields'. The actual ID of the column I was looking for was actually 'on_ebay', so I was able to query this user defined field simply:
http://[server]:[port]/api/inventory/parts?$query=on_ebay eq 'Y'
I'm attempting to write a SPARQL query which would allow me to find all nodes which are reachable from a given node. At the moment every edge has the prefix http://www.foo.com/edge# and there are 3 possible edges (uses, extends, implements). While I can get the correct result from "?start (edge:uses | edge:implements | edge:extends)* ?reached " I would like to reduce that down to one statement, some kind of wildcard after edge:, so that if I add more edge types then I wouldn't need to extend the query. Is this possible?
see this SPARQL - Restricting Result Resource to Certain Namespace(s)
If you know it's always going to be in the same namespace, you could have something looking like:
?start ?edge ?reached
FILTER(REGEX(STR(?var), "^http://www.foo.com/edge#"))
I have given some web services to access informations.
The first thing that i have tries to expand a node . And i have done that successfully with following code
http://www.domain.com/ODataService/WorkService.svc/CaseStudies?format=json&$expand=ServiceOfferings
Now i want to filter ServiceOfferingID that i will get when expanding ServiceOfferings .
How can use filter option against a expanded collection
http://www.domain.com/ODataService/WorkService.svc/CaseStudies?format=json&$expand=ServiceOfferings&$filter=ServiceOfferings.ServiceOfferingID eq 127
But its not working. What is right way to do the same
The query you'll need to write depends on the cardinality of the expanded collection.
Here are some examples that use the public sample OData Northwind service, provided by odata.org.
An order is always done by exactly one customer.
Find the orders made by a customer with a specific name:
http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$expand=Customer&$filter=Customer/CompanyName eq 'Vins et alcools Chevalier'. This is equivalent to the answer of Dhawal.
A customer can issue many orders.
Use the quantifiers all or any to specify whether you want at least one, or all of the orders to obey your conditions.
Find customers for which one or more orders have been processed by a specific employee:
http://services.odata.org/V3/Northwind/Northwind.svc/Customers?$expand=Orders&$filter=Orders/any(o: o/EmployeeID eq 9)
Find customers that haven't ordered anything for a long time:
http://services.odata.org/V3/Northwind/Northwind.svc/Customers?$expand=Orders&$filter=Orders/all(o: o/OrderDate lt DateTime'1997-01-01')
You can call http://services.odata.org/V3/Northwind/Northwind.svc/$metadata and inspect the NavigationProperty elements, to see which relations exist.
<NavigationProperty Name="Orders"
Relationship="NorthwindModel.FK_Orders_Customers"
ToRole="Orders"
FromRole="Customers"/>
Then, look for an association with that name and you'll find the cardinality:
<Association Name="FK_Orders_Customers">
<End
Type="NorthwindModel.Customer"
Role="Customers"
Multiplicity="0..1"/>
<End
Type="NorthwindModel.Order"
Role="Orders"
Multiplicity="*"/>
...
Navigating a one-to-many relationship like this: http://services.odata.org/V3/Northwind/Northwind.svc/Customers?$expand=Orders&$filter=Orders/EmployeeID eq 9, will give you: "The parent value for a property access of a property 'EmployeeID' is not a single value. Property access can only be applied to a single value."
Navigating a many-to-one relationship with all or any, like http://services.odata.org/V3/Northwind/Northwind.svc/Orders?$expand=Customer&$filter=Customer/any(c: c/CompanyName eq 'Vins et alcools Chevalier'), will give you:
"Any/All may only be used following a collection."
By the way, all() and any() are actually the Universal quantifier, ∀() and the existential quantifier, ∃(), respectively, which you may remember from math class.
Filtering by child object's properties is supported in oData.
Here is an example:
http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=Customer/Country eq 'Germany'
Might be helpful for someone
GET serviceRoot/People?$expand=Trips($filter=Name eq 'Trip in US')
In OData the Filter command only works on the top level element. For your filter to work you would need to have the following URL
http://www.example.com/ODataService/WorkService.svc/CaseStudies(x)/ServiceOfferings?format=json&$filter=ServiceOfferingID eq 127
Obviously this isn't the query you are trying to write, but behind the scenes your query is being converted to an expression tree which has a root expression based on the top level element.
If you really required to filter the data you could potentially intercept the query and write your own expression as below:
[QueryInterceptor("CaseStudies")]
public Expression<Func<CaseStudie, bool>> CaseStudieFilter()
{
<Expression here>
}
You can also accomplish this through a webget on the service. I have had to do something similar to filter by properties of properties.