Discuss Special page "SearchByProperty"

From semantic-mediawiki.org

Contents

Thread titleRepliesLast modified
The same information via 'ask' or 'show'610:49, 15 June 2018

The same information via 'ask' or 'show'

Is it possible to get the same information via #ask or #show parser functions?

04:59, 10 April 2018

#show is used in the scope of a single page already known when creating the query while you use #ask to select pages you currently not yet know matching your criteria. See this info.

09:45, 10 April 2018

Thank you for the answer. I read the page you give the link to and could not find the answer. Let me put it in a different way: "Is it possible to insert in an article the list of property values similar to what we get in SearchByProperty special page?"

04:22, 11 April 2018

Ah, good point. I actually did not understand your original question and I was wondering why the question landed here.

To get a list of pages and their values you would do:

{{#ask:
 [[Has installation type::+]]
 |?Has installation type
 |mainlabel=
 |headers=hide
}}

or respectively

{{#ask:
 [[Has installation type::new]]
 |?Has installation type
 |mainlabel=
 |headers=hide
}}

If you only need the different values added to a property you need the help of the Arrays extension to do:

{{#arraydefine: values
 |{{#ask:
  [[Has installation type::+]]
  |?Has installation type
  |mainlabel=-
  |headers=hide
 }}
 |,
 |unique, sort=desc
}}

followed by

{{#arrayprint: values }}

I guess this is what you want to do. I am not aware of a way to directly simulate the output of this special page without using "tricks".

09:47, 11 April 2018

Thank you very much! That is what I was looking for. But now, when I've found it, I've discovered two more questions:

1) #ask generates list with comma as delimiter (separator), so if there is comma in resulting values the list become messed up. How to change delimiter in #ask so #arraydefine will split the list correctly? Inline queries, Selecting pages and Result formats give no clue.

2) How to handle "see more" link in long list to leave this link the last, when sorting, but not to sort with the query result putting somewhere in the middle?

10:53, 18 April 2018

In a lot of cases issues appear along the way when constructing queries.

1) Looking for a solution via result formats was right. The particular format used is "list", so you can use it's "sep" parameter to define another separator between results and let "arraydefine" work with it:

{{#arraydefine: values
 |{{#ask:
  [[Has installation type::+]]
  |?Has installation type
  |mainlabel=-
  |headers=hide
  |format=list
  |sep=;
 }}
 |;
 |unique, sort=desc
}}

2) Probably you do not want to have the "see more" link at all, since this is not a reusable value. Add the "searchlabel" parameter and hide the standard output. Also increase the result limit to a value higher than the number of expected results to make sure that you do not cut off valid values.

{{#arraydefine: values
 |{{#ask:
  [[Has installation type::+]]
  |?Has installation type
  |mainlabel=-
  |headers=hide
  |format=list
  |sep=;
  |searchlabel=
  |limit=500
 }}
 |;
 |unique, sort=desc
}}

Note configuration parameter $smwgQMaxInlineLimitSets the maximal number of rows ever printed by queries in connection with the limit parameter.

21:39, 19 April 2018