Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create V2 for Search #478

Merged
merged 185 commits into from
Jul 25, 2017
Merged

Create V2 for Search #478

merged 185 commits into from
Jul 25, 2017

Conversation

tobiasschweizer
Copy link
Contributor

@tobiasschweizer tobiasschweizer commented Mar 27, 2017

This makes a start at implementing #530. The rest will be done in subsequent pull requests.

@mrivoal
Copy link

mrivoal commented Mar 27, 2017

I am not sure whether this is relevant at this stage, but as for the design of V2 API, I just want to be sure that the requirements to run queries throughout various (and customed) properties of 2 resource classes will be taken into account (such as expressed here: #227).

This is just a reminder that @loicjaouen has begun to work on an graphic interface (as a proposition for Salsah 1.5/V1 API but with Salsah 2.0 and V2 API in mind), but unfortunately, he hasn't had much time to dedicate to it yet.

@tobiasschweizer
Copy link
Contributor Author

We have to do that together, absolutely.

As for now, I am trying to have a prove of concept at the end of the week for the fulltext search v2. The Response format should be JSON-LD.

I was fighting with responder manager conf ...

@tobiasschweizer
Copy link
Contributor Author

tobiasschweizer commented Mar 27, 2017

@benjamingeer @subotic Hey masters of disaster, does this setup for v2 look reasonable to you?

sorry, I mentioned the wrong geer

Copy link

@benjamingeer benjamingeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a naming convention or package name convention to separate internal messages from API messages: #424

In RouteUtilV2, we should get rid of the Knora-specific status code returned in the API response; the HTTP status code is enough. If an exception is thrown, the Knora-specific status code in V1 comes from KnoraExceptionHandler. I guess this means that KnoraExceptionHandler should become KnoraExceptionHandlerV1 and KnoraExceptionHandlerV2.

We should make a UserProfileV2 and clean it up. No reason to have something like UserDataV1 as a separate class. I think means that most of what's in usermessages needs to be shared by V1 and V2.

@tobiasschweizer
Copy link
Contributor Author

tobiasschweizer commented Mar 28, 2017

PREFIX knora-base: <http://www.knora.org/ontology/knora-base#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
CONSTRUCT { 
	?matchingSubject ?matchingProperty ?literal .
    ?matchingSubject knora-base:attachedToUser ?valueCreatorMatchingSubject ;
            knora-base:hasPermissions ?valuePermissionsMatchingSubject .
    ?matchingSubject a ?typeMatchingSubject .
    
    ?resource ?prop ?matchingSubject .
    ?resource rdfs:label ?label .
    ?resource a ?typeResource .
    ?resource knora-base:attachedToUser ?valueCreatorResource ;
            knora-base:hasPermissions ?valuePermissionsResource .
}

WHERE {
    
    ?matchingSubject ?matchingProperty ?literal .
    ?literal <http://www.ontotext.com/owlim/lucene#fullTextSearchIndex> 'Zeitglöcklein' .
    
    GRAPH <http://www.ontotext.com/explicit> {
        ?matchingSubject ?matchingProperty ?literal .
        ?matchingSubject a ?typeMatchingSubject .
    }
    
    ?matchingSubject knora-base:isDeleted false .
    
    ?matchingSubject knora-base:attachedToUser ?valueCreatorMatchingSubject ;
    	knora-base:hasPermissions ?valuePermissionsMatchingSubject .
    
    
    OPTIONAL {
    	?resource knora-base:hasValue ?matchingSubject .
    
    	GRAPH <http://www.ontotext.com/explicit> {
        	?resource ?prop ?matchingSubject .
            ?resource a ?typeResource .
    	}
    
    	?resource knora-base:isDeleted false .
    
        ?resource rdfs:label ?label .
        
        
        
        ?resource knora-base:attachedToUser ?valueCreatorResource ;
        	knora-base:hasPermissions ?valuePermissionsResource .
    }
}

@loicjaouen
Copy link
Contributor

For info: here is the first mockup to make a search form we did some time ago (it doesn't include suggested improvements that we collected):
https://platec.unil.ch/test/xtdsrch/

You can click on Persons and Works to list the items you can play with.
The simple search, select Person or Work depending what you look for, type ez press search and you get a list of results.
The extended search allows to do search by exploring the graph, like saying works from authors who published in 1912 (change it to 1916 and the final result changes quite a bit):
extended search clickable demo

@benjamingeer benjamingeer mentioned this pull request Jul 17, 2017
Tobias Schweizer and others added 19 commits July 18, 2017 11:46
# Conflicts:
#	webapi/src/main/scala/org/knora/webapi/OntologyConstants.scala
#	webapi/src/main/scala/org/knora/webapi/responders/v1/GroupsResponderV1.scala
#	webapi/src/main/scala/org/knora/webapi/responders/v1/ListsResponderV1.scala
#	webapi/src/test/scala/org/knora/webapi/e2e/v1/GroupsRouteV1E2ESpec.scala
#	webapi/src/test/scala/org/knora/webapi/e2e/v1/ProjectsRouteV1E2ESpec.scala
#	webapi/src/test/scala/org/knora/webapi/e2e/v1/UsersRouteV1E2ESpec.scala
#	webapi/src/test/scala/org/knora/webapi/responders/v1/GroupsResponderV1Spec.scala
#	webapi/src/test/scala/org/knora/webapi/responders/v1/ListsResponderV1Spec.scala
#	webapi/src/test/scala/org/knora/webapi/responders/v1/ProjectsResponderV1Spec.scala
…s for API V1 and V2 responders.

- Add a router for PersistentMapResponderV2.
…rql queries

- in parallel, the same tests are added for v1 extended search
- add the same tests for extended search v1 (same results expected)
@benjamingeer
Copy link

Some notes on how to generate V2 search SPARQL for Fuseki or for another triplestore where we can't use inference:

Here's a comparison of what we do for V1 extended search on GraphDB vs. Fuseki.

Matching a property of a resource

We want to match the property and its subproperties.

GraphDB

?resource <@searchCriterion.propertyIri> ?valueObject@index .

Fuseki

?p@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> .
?resource ?p@index ?valueObject@index .

Matching a link to another resource

We match:

  • The user-supplied link property and its subproperties.
  • The corresponding link value property and its subproperties.

We find out the actual link property, and we use it to match the knora-base:LinkValue.

GraphDB

?resource <@searchCriterion.propertyIri> ?targetResource@index .
?resource <@{searchCriterion.propertyIri}Value> ?valueObject@index .

GRAPH <http://www.ontotext.com/explicit> {
    ?resource ?linkProperty@index ?targetResource@index .
}

?targetResource@index rdfs:label ?literal@index ;
    knora-base:isDeleted false ;
    knora-base:attachedToUser ?targetResourceCreator@index ;
    knora-base:attachedToProject ?targetResourceProject@index ;
    knora-base:hasPermissions ?targetResourcePermissions@index .

?valueObject@index rdf:type knora-base:LinkValue ;
    rdf:subject ?resource ;
    rdf:predicate ?linkProperty@index ;
    rdf:object ?targetResource@index .

Fuseki

?linkProperty@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> .
?resource ?linkProperty@index ?targetResource@index .
?linkValueProperty@index rdfs:subPropertyOf* <@{searchCriterion.propertyIri}Value> .
?resource ?linkValueProperty@index ?valueObject@index .

?targetResource@index rdfs:label ?literal@index ;
    knora-base:isDeleted false ;
    knora-base:attachedToUser ?targetResourceCreator@index ;
    knora-base:attachedToProject ?targetResourceProject@index ;
    knora-base:hasPermissions ?targetResourcePermissions@index .

?valueObject@index rdf:type knora-base:LinkValue ;
    rdf:subject ?resource ;
    rdf:predicate ?linkProperty@index ;
    rdf:object ?targetResource@index .

Matching the class of a resource

GraphDB

?resource a <@restypeIri> .

Fuseki

?resClass rdfs:subClassOf* <@restypeIri> .
?resource a ?resClass .

…th Fuseki.

- Don't put knora-api.ttl in the triplestore, since we won't need to query it and it will be removed.
@benjamingeer
Copy link

We're going to merge this PR as is, because the basic API v2 infrastructure is now needed for other PRs. We'll make another PR to finish the v2 search functionality.

@benjamingeer benjamingeer merged commit ea0b7f7 into develop Jul 25, 2017
@benjamingeer benjamingeer deleted the wip/design-V2-search branch July 25, 2017 15:53
@benjamingeer benjamingeer mentioned this pull request Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants