AKSW / OntoWiki

Semantic data wiki as well as Linked Data publishing engine
https://ontowiki.net
205 stars 51 forks source link

Date filtering not possible #125

Closed seebi closed 12 years ago

seebi commented 12 years ago

Please refer to https://groups.google.com/forum/?fromgroups=#!topic/ontowiki-user/6RA-qhguZRs

Jeff, can you provide a minimal not-working example of a graph in turtle here, where your query fails? Can you provide the query too?

jdmcpher commented 12 years ago

Hi Sebastian,

I'm not sure how to provide a minimal not-working example of a graph in turtle. Could you provide instructions on how to do that?

In the meantime, I have a new update. Using a different syntax for the query, I have gotten interesting results.

SELECT DISTINCT *
FROM <RDSimport_DateTime>
WHERE {
    ?Memorandum p1:hasCreationDate ?hasCreationDate.
    ?Memorandum p1:hasSubject ?hasSubject.
    ?Memorandum p1:hasAuthor ?hasAuthor.
    ?Memorandum p1:hasRecipient ?hasRecipient.
    ?Memorandum p1:hasMemoNumber ?hasMemoNumber.
    ?Memorandum p1:hasNewFile ?hasNewFile.
    FILTER (xsd:dateTime(?hasCreationDate) = xsd:dateTime("1978-01-08T00:00:00Z")).
}
LIMIT 10

Using this syntax for the filter, the logic works for "=", ">", ">=", and "!=". Anything containing the "<" symbol returns all memorandum instances. Is this because the "<" symbol is also used to open brackets? If this symbol works, the date filtering will be working properly and the issue is, to the best of my knowledge, taken care of. That being said, I don't think this takes care of queries on other datatype properties, like ones that contain integers.

Thank you for your time, -Jeff

seebi commented 12 years ago

Hi jeff, just paste an example resource turtle code from the source tab here so that we can import that.

jdmcpher commented 12 years ago

Hi Sebastian, is this what you're looking for?

# Exported with the Erfurt API - http://aksw.org/Projects/Erfurt

@base <RDSimport_DateTime> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix p1: <http://www.owl-ontologies.com/Ontology1338823772.owl#> .
@prefix protege: <http://protege.stanford.edu/plugins/owl/protege#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix swrl: <http://www.w3.org/2003/11/swrl#> .
@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix xsp: <http://www.owl-ontologies.com/2005/08/07/xsp.owl#> .

<http://www.owl-ontologies.com/Ontology1344272444.owl#1> p1:hasAuthor <http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff_McPherson> ;
                                                         p1:hasCreationDate "2011-03-10T00:00:00Z"^^xsd:dateTime ;
                                                         p1:hasMemoNumber "1"^^xsd:string ;
                                                         p1:hasNewFile "25_Alpha Project.pdf"^^xsd:string ;
                                                         p1:hasOriginalFile "C:\\Users\\Administrator\\Documents\\Samples\\TEXTSample1.txt"^^xsd:string ;
                                                         p1:hasProject <http://www.owl-ontologies.com/Ontology1344272444.owl#Beta> ;
                                                         p1:hasRecipient <http://www.owl-ontologies.com/Ontology1344272444.owl#Jay_Breindel> ;
                                                         p1:hasSubject "Pizza"^^xsd:string ;
                                                         a p1:Memorandum .

<http://www.owl-ontologies.com/Ontology1344272444.owl#2> p1:hasAuthor <http://www.owl-ontologies.com/Ontology1344272444.owl#Ian_Grosse> ;
                                                         p1:hasCreationDate "2009-04-09T00:00:00Z"^^xsd:dateTime ;
                                                         p1:hasMemoNumber "2"^^xsd:string ;
                                                         p1:hasNewFile "6_Beta Project.pdf"^^xsd:string ;
                                                         p1:hasOriginalFile "C:\\Users\\Administrator\\Documents\\Samples\\TEXTSample2.txt"^^xsd:string ;
                                                         p1:hasProject <http://www.owl-ontologies.com/Ontology1344272444.owl#Gamma> ;
                                                         p1:hasRecipient <http://www.owl-ontologies.com/Ontology1344272444.owl#Sundar_Krishnamurty> ;
                                                         p1:hasSubject "Hamburger"^^xsd:string ;
                                                         a p1:Memorandum .

<http://www.owl-ontologies.com/Ontology1344272444.owl#5> p1:hasAuthor <http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff_McPherson> ;
                                                         p1:hasCreationDate "2011-01-10T00:00:00Z"^^xsd:dateTime ;
                                                         p1:hasMemoNumber "5"^^xsd:string ;
                                                         p1:hasNewFile "100_School.pdf"^^xsd:string ;
                                                         p1:hasOriginalFile "C:\\Users\\Administrator\\Documents\\Samples\\TEXTSample5.txt"^^xsd:string ;
                                                         p1:hasProject <http://www.owl-ontologies.com/Ontology1344272444.owl#Lambda> ;
                                                         p1:hasRecipient <http://www.owl-ontologies.com/Ontology1344272444.owl#Laura_McPherson> ;
                                                         p1:hasSubject "School"^^xsd:string ;
                                                         a p1:Memorandum .

<http://www.owl-ontologies.com/Ontology1344272444.owl#4> p1:hasAuthor <http://www.owl-ontologies.com/Ontology1344272444.owl#Ian_Grosse> ;
                                                         p1:hasCreationDate "2011-06-23T00:00:00Z"^^xsd:dateTime ;
                                                         p1:hasMemoNumber "4"^^xsd:string ;
                                                         p1:hasNewFile "65_Beta Project.pdf"^^xsd:string ;
                                                         p1:hasOriginalFile "C:\\Users\\Administrator\\Documents\\Samples\\TEXTSample4.txt"^^xsd:string ;
                                                         p1:hasProject <http://www.owl-ontologies.com/Ontology1344272444.owl#Delta> ;
                                                         p1:hasRecipient <http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff_McPherson> ;
                                                         p1:hasSubject "Cheese"^^xsd:string ;
                                                         a p1:Memorandum .

<http://www.owl-ontologies.com/Ontology1344272444.owl#3> p1:hasAuthor <http://www.owl-ontologies.com/Ontology1344272444.owl#Sundar_Krishnamurty> ;
                                                         p1:hasCreationDate "1978-01-08T00:00:00Z"^^xsd:dateTime ;
                                                         p1:hasMemoNumber "3"^^xsd:string ;
                                                         p1:hasNewFile "1_Gamma Project.pdf"^^xsd:string ;
                                                         p1:hasOriginalFile "C:\\Users\\Administrator\\Documents\\Samples\\TEXTSample3.txt"^^xsd:string ;
                                                         p1:hasProject <http://www.owl-ontologies.com/Ontology1344272444.owl#Alpha> ;
                                                         p1:hasRecipient <http://www.owl-ontologies.com/Ontology1344272444.owl#Jack_Wileden> ;
                                                         p1:hasSubject "Turkey"^^xsd:string ;
                                                         a p1:Memorandum .
seebi commented 12 years ago

nate, can you please investigate here?

white-gecko commented 12 years ago

Hey Jeff, I have tested all the queries you have posted on the list and here in this issue. Except for the first from your post on 14. Sep all of them worked for me and I think the gave the right results.

The following query is missing a data type in the filter. "1978-01-08T00:00:00Z" is treated as a string and thus not comparable with the dates in the model.

PREFIX p1: <http://www.owl-ontologies.com/Ontology1338823772.owl#>

SELECT DISTINCT ?resourceUri
WHERE {
?resourceUri <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.owl-ontologies.com/Ontology1338823772.owl#Memorandum> .
?resourceUri <http://www.owl-ontologies.com/Ontology1338823772.owl#hasCreationDate> ?p1hasCreationDate
FILTER (!isBLANK(?resourceUri))
FILTER (?p1hasCreationDate > "1978-01-08T00:00:00Z")
}
LIMIT 10 

Are you using the MySQL back-end or virtuoso?

white-gecko commented 12 years ago

I have tested all the queries with MySQL back-end as well and they are giving the same (in my eyes correct) results as virtuoso.

Furthermore I have investigated the one query from your post on 14. Sep which I couldn't execute:

PREFIX p1: <http://www.owl-ontologies.com/Ontology1338823772.owl#>

SELECT *
WHERE {

    ?Memorandum p1:hasCreationDate ?hasCreationDate.
    ?Memorandum p1:hasSubject ?hasSubject.
    ?Memorandum p1:hasAuthor ?hasAuthor.
    ?Memorandum p1:hasRecipient ?hasRecipient.
    ?Memorandum p1:hasMemoNumber ?hasMemoNumber.
    FILTER (?hasAuthor = <http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff>).

}
LIMIT 10 

First I had a mistake (a linebreak in a URI) when I copied it from the post. Then I have executed the query and got no results, which is correct because there is no resource http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff in the model, but a resource http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff_McPherson. If you change the query to #Jeff_McPherson you will get 2 results.

jdmcpher commented 12 years ago

Hi Nate,

I am using a MySQL back-end. The only filter I was having trouble with was dates. The "FILTER (?hasAuthor = http://www.owl-ontologies.com/Ontology1344272444.owl#Jeff)." was written that way just so that I didn't post my last name on the forum.

Please try running queries on my OntoWiki installation edesignwiki.ecs.umass.edu/OntoWiki/. I have been using the RDSimport_DateTime knowledge model so please select that and then try running some queries.

The query

SELECT DISTINCT *
FROM
WHERE {
    ?Memorandum p1:hasCreationDate ?hasCreationDate.
    ?Memorandum p1:hasSubject ?hasSubject.
    ?Memorandum p1:hasAuthor ?hasAuthor.
    ?Memorandum p1:hasRecipient ?hasRecipient.
    ?Memorandum p1:hasMemoNumber ?hasMemoNumber.
    ?Memorandum p1:hasNewFile ?hasNewFile.
    FILTER (xsd:dateTime(?hasCreationDate) = xsd:dateTime("1978-01-08T00:00:00Z")).
}
LIMIT 10

returns correct results for me. 1978-01-08T00:00:00Z is the "oldest" date in the knowledge model. When you change from "=" to "<" in the filter, you get all instances as a result (you shouldn't get any). However, when you change to ">", it works (you get all instances other than the one with the date 1978-01-08T00:00:00Z). This is what led me to believe there is a problem with the "<" symbol.

Thanks and let me know if you need anymore information. -Jeff

white-gecko commented 12 years ago

Ok, I could reproduce it on you system and on my local system as well. It only happens with the MySQL backend.

jdmcpher commented 12 years ago

Would you recommend that I switch to Virtuoso? Or is this an issue that can be addressed?

seebi commented 12 years ago

yes, definitely!

white-gecko commented 12 years ago

yes to both :-) Its always a good idea to use virtuoso, but I will also try to fix the problem.

jdmcpher commented 12 years ago

Why is it that Virtuoso is better in this application?

seebi commented 12 years ago

virtuoso is a database specifically optimized for use as an RDF store is much faster than the mysql backend (as well as that it has better support for SPARQL)

jdmcpher commented 12 years ago

Hi Nate,

Have you made any progress on this issue? I am planning to install Virtuoso today. Do you know if I can keep my MySQL installation of OntoWiki on the computer and install Virtuoso on the same machine as long as I avoid port conflicts? The reason I ask is because I would like to be able to go back to my working MySQL installation if I have any issues with Virtuoso.

Thanks, -Jeff

white-gecko commented 12 years ago

Hey Jeff, you can just install virtuosos and change the config.ini of your OntoWiki.

You need to change store.backend = zenddb to virtuoso and keep the zenddb settings as they are. If you want to switch back to using mysql you just have to change back this one line.

You should reset the session (Main Menu: "Debug > Reset Session" [1]) before this change to avoid errors.

[1] The Debug menu is only visible if you are logged in

Kind regards Nate

white-gecko commented 12 years ago

I have added a Unit test which fails due to this issue: http://owdev.ontowiki.net/job/Erfurt/70/changes

white-gecko commented 12 years ago

This is an Erfurt issue, so I created a new one there: AKSW/Erfurt#35