Василиса▶ Я жду вашего обращения. Что Вы хотите узнать?
Логотип
Wikidata:SPARQL query service/Query Helper - Wikidata Wikidata:SPARQL query service/Query HelperFrom Wikidata< Wikidata:SPARQL query service Translate this page Other languages:English • ‎ dansk  • ‎ français  • ‎ svenska  • ‎ русский  • ‎ العربية  • ‎ 中文  • ‎ 日本語 Query.Wikidata.org Query Helper

Query Helper allows you to create or modify an existing query without knowing SPARQL.

When working with the tool it will modify the SPARQL query, based on the input you provide in the visual interface, and vice versa.

It is displayed on the left side of the query editor.

ContentsWhat are the limitations?[ edit ]

This is an experimental tool and may break your SPARQL query .

JSON serialization should not contain new lines.Template can be placed anywhere in the query: at the top, at the bottom for example.The content of the template will be added to the URL of the query. Some issues may occurs for that reason.How to create a Query?[ edit ]File:Wikidata Query - Query Helper - Build query from scratch.webm Play media Create query zoo that keeps polar bear and lion

This section will show how you can create a query from scratch with the Query Helper.

In this example we will query all instances of zoo that are keeping a polar bear and a lion.

Add 'instance of zoo', 'species kept polar bear' and 'species kept lion' filter[ edit ]Click on 'Filter'Click on the combo box and enter 'zoo'Select the 'zoo (Q43501)' item from the combo boxClick on 'Filter' and select 'polar bear (Q33609)'Click on 'Filter' and select 'lion (Q140)'Add 'official website', 'image', 'coordinate location', 'inception' and 'species kept' columns[ edit ]Click on 'Show' and select 'official website (P856)'Click on 'Show' and select 'image (P18)'Click on 'Show' and select 'coordinate location (P625)'Click on 'Show' and select 'inception (P571)'Click on 'Show' and select 'species kept (P1990)'How to modify a Query?[ edit ] Query Helper - Edit 'Cat Query'

This section will show how you can edit a query with the Query Helper

Change 'cat' to 'zoo'[ edit ]Select the 'Cat Query' from the examplesClick on 'cat' to modify the valueClick on the combo box and enter 'zoo'Select the 'zoo (Q43501)' item from the combo box

The query will now find items that have 'instance of zoo' instead of 'instance of cat'

Add 'country Germany' filter[ edit ]Click on 'Filter' buttonEnter 'Germany'Select 'Germany (Q183)'Click on 'instance of' from 'instance of Germany' to modify the valueClick on the select box and enter 'Country'Select country (P17) item

The query will now only find items that have 'instance of zoo' and 'country Germany'

Add 'inception' and 'image' columns[ edit ]Click on 'Show' buttonEnter 'inception'Select 'inception (P571)' itemClick on 'Show' buttonEnter 'image'Select 'image (P18)'

The query result now has two additional columns 'image' and 'inception' and can be displayed as a Timeline or Image Grid .

Query Templates[ edit ]Use a Query Template[ edit ] Query Helper - Query Template Largest cities with female head of government

Queries that have a Query Template defined will show the defined textual representation of this query inside of the Query Helper. Query Helper allows you to create or modify an existing query without knowing SPARQL.

When working with the tool it will modify the SPARQL query, based on the input you provide in the visual interface, and vice versa.

It is displayed on the left side of the query editor.

Blue items in this textual representation can be clicked to modify them.

Defined suggestions will be shown or a text can be entered to search for a replacement.

When selecting one of the items in the list it will replace the item in the textual representation and the SPARQL query.

You can find all the queries in the Query Examples List that have a defined Query Template by searching for '#TEMPLATE' in the page text.

Create a Query Template[ edit ]

Query templates can be created by providing a template definition. Here is an example query with a template definition.

The definition is expressed in JSON and inserted as SPARQL comment to the query like this:

#TEMPLATE=[JSON_DEFINITION]

JSON definition example:

{"template":"Largest ?c with ?sex head of government","variables":{"?sex":{},"?c":{"query":"SELECT DISTINCT ?id WHERE { ?c wdt:P31 ?id. ?c p:P6 ?mayor. }"}}}
Key Value Example Description SPARQL Query
template This text will be shown to the user as description for the query.

In the text you can define variables that will be replaced by actual values.

Largest ?c with ?sex head of government This will define two variables within the text:

?c and ?sex

The values for this variables must be defined

in the SPARQL query.




BIND

(

wd

:

Q6581072

AS

?sex

)

BIND

(

wd

:

Q515

AS

?c

)
variables In this section you have to define the variables from the template.

You can optionally define a SPARQL query that is used for suggesting values for that variable.




"?sex"

:

{}

,

"?c"

:

{

"query"

:

"[SPARQL]"

}
This will define two variables:

?c and ?sex

For the variable ?c there is a SPARQL query defined that will suggest Items.




SELECT

DISTINCT

?id

WHERE

{

?c

wdt

:

P31

?id

.

?c

p

:

P6

?mayor

.

}
The SPARQL query from the Query Template will be embedded into this query to display the result with label, description. If ?count is provided then it will be sorted by desc(?count):



SELECT

?id

?label

?description

WITH

{

[

QUERY

]

}

AS

%inner

WHERE

{

INCLUDE

%inner

?id

rdfs

:

label

?label

.

?id

schema

:

description

?description

.

FILTER

((

LANG

(

?label

))

=

"en"

)

FILTER

((

LANG

(

?description

))

=

"en"

)

}

ORDER BY

DESC

(

?count

)

LIMIT

20
Retrieved from " https://www.wikidata.org/w/index.php?title=Wikidata:SPARQL_query_service/Query_Helper&oldid=1288852359 " Category : Wikidata:SPARQL query service Navigation menuPersonal toolsNot logged in Talk Contributions Create account Log in Namespaces Project page Discussion VariantsViews Read Edit View history MoreSearch
Navigation Main page Community portal Project chat Create a new Item Recent changes Random Item Query Service Nearby Help Donate Lexicographical data Create a new Lexeme Recent changes Random Lexeme Tools What links here Related changes Special pages Permanent link Page information Wikidata item Print/export Create a book Download as PDF Printable version In other projects Wikimedia Commons In Wikipedia Add links This page was last edited on 9 October 2020, at 21:09.All structured data from the main, Property, Lexeme, and EntitySchema namespaces is available under the Creative Commons CC0 License ; text in the other namespaces is available under the Creative Commons Attribution-ShareAlike License ; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Privacy policy About Wikidata Disclaimers Mobile view Data access Developers Statistics Cookie statement Wikimedia Foundation Powered by MediaWiki
© 2014-2021 ЯВИКС - все права защищены.
Наши контакты