Quantcast

#ask query syntax

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

#ask query syntax

Tom Hutchison
Hi,

Was wondering if this looks correct. I am using the Variables extension to
pass a template variable to a global variable for use across the page.

{{#ask: [[Category:Person]] {{#arraymap:{{{Property
values|}}}|;|x|[[Property1::{{#var:global1}}]]|
[[Property2::{{#var:global2}}]]| OR }} ![[Person::{{PAGENAME}}]]

When I run this all I get for a result is the PAGENAME itself.

I have a feeling it is my Propery1 and Property2, as they are page
properties, not strings. This:

{{#ask: [[Category:Person]] [[Property1::{{#var:global1}}]] OR
[[Property2::{{#var:global2}}]]

yeilds what I want, a list of pages that match Property1 or Property2 to the
values to that page. However it lists the {{PAGENAME}} in the list, which is
redundant to what I want in results.

Thanks
Tom


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: #ask query syntax

badon
It appears you are using #arraymap incorrectly. You need to put your #ask query INSIDE the arraymap, in the location for the "formula" parameter. I have written up some detailed examples of how to use it here:

http://www.mediawiki.org/wiki/User:Badon/Extension:Semantic_Forms/Manual/Multiple_values_for_the_same_field

I think the detailed examples are very helpful, so I hope you agree. I actually prefer using arrays instead of arraymap. The extension is officially a beta, but I have only found one small bug in it so far, which was immediately fixed when I reported it, so I think you should give it a try and see if you like it:

http://www.mediawiki.org/wiki/Extension:Arrays

Also, in order to get rid of the page results, I think you need to structure your query with a mainlabel parameter that looks like this:

mainlabel=-

the minus tells the ask query to eliminate the page results. You can find documentation for that here:

http://semantic-mediawiki.org/wiki/Help:Inline_queries

If you need any other help, let me know.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: #ask query syntax

Tom Hutchison
Hi Badon

Yes, I'm lost. I am referring to this page:
http://smw.referata.com/wiki/Excluding_a_page_from_an_inline_query 

I am trying to make a list of pages that match one or two properties of the the page I am currently on. I need to query two properties, which only contain 1 possible value, not multiple values. I think the links you provided are for properties with multiple values. The properties I am trying to compare are 1 value.

Trying to map this out.

Current page contains a #ask query---> List the pages that Match the Current page’s Property 1 or Property 2 but Exclude the current page from the results.

I did go back and add 3 additional properties to all pages, all with a String value, since the 3 properties I was trying to query all hold a page name.

As I said, this works for the query.

{{#ask: [[Category:Person]] [[Property1::{{#var:global1}}]] OR [[Property2::{{#var:global2}}]]}} Will list all pages that have a matching Property 1 or Property 2 with the current page.

It would be so easy if the #ask query contained a  NOT function. OR, works, AND does too, in a way. Eliminate the OR and the #ask looks for all pages that match both Property 1 and Property 2. I guess I could template out the results table and eliminate the page that way, but I would like to understand the web page I referred to above.

Thanks
Tom





------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: #ask query syntax

badon
OK, it appears that the usage of #arraymap is not needed in this case. It also looks like this tip:

http://smw.referata.com/wiki/Excluding_a_page_from_an_inline_query

Is a little more complicated than it needs to be, and so is causing some confusion. I think what you really want is something like this:

[[Person::{{PAGENAME}}| ]]
{{#ask: [[Category:Person]] [[Property1::{{#var:global1}}]] OR [[Property2::{{#var:global2}}]] ![[Person::{{PAGENAME}}]]}}

That will silently store the {{PAGENAME}} as a Person property on the page you are on, and then the following query will be able to remove the page you are on from the results. I haven't tried that code myself, so tell me if it works or not.

Keep in mind that if {{#var:global1}} or {{#var:global2}} are undefined, the query will produce an error. If they're never undefined, then the above code should be all you need. If they might be undefined, we'll have to add some conditional #if code to make sure the query is always valid (or not run the query) if one or both of the properties are undefined.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: #ask query syntax

Tom Hutchison
Thanks Baden!

This didn't work....
[[Person::{{PAGENAME}}| ]]
{{#ask: [[Category:Person]] [[Property1::{{#var:global1}}]] OR
[[Property2::{{#var:global2}}]] ![[Person::{{PAGENAME}}]]}}

but..it got me to thinking and I figured it out and it works. This is a
partial solution. The ! had to be moved in front of the {{PAGENAME}}, not
sure why. Person, was the new Property I happened to set as a string on
every page so I think it is the extra Property as a string that needs to be
there as the eliminator of the current page. I think the fact all pages have
the Person property set to the page name might be why I needed to move the !
to directly in front of the {{PAGENAME}}. Anyway, my first try of this
worked half way.

[[Person::{{PAGENAME}}| ]]
{{#ask: [[Category:Person]] [[Property1::{{#var:global1}}]] OR
[[Property2::{{#var:global2}}]] [[Person::!{{PAGENAME}}]]
| ?Property1
| ?Property2
| format=table
| default=There are no matches.
}}

Then I realized, the OR was telling the #ask, if they match (Property1) OR
(Property2 !(NOT) the Current page). If the current page matched Property 1,
it was still showing in the results. I need to tell the #ask query if it
matched (Property1 but (NOT)!Current page) OR (Property2 but (NOT)!Current
page) show the results. The OR must be a hard divider in the statement. So
this syntax works like a charm.

[[Person::{{PAGENAME}}| ]]
{{#ask: [[Category:Person]] [[Property1::{{#var:global1}}]]
[[Person::!{{PAGENAME}}]] OR
[[Property2::{{#var:global2}}]] [[Person::!{{PAGENAME}}]]
| ?Property1
| ?Property2
| format=table
| default=There are no matches.
}}

This last syntax was why I thought I needed to use an array, I was querying
two properties of which either matched, but trying to eliminate the one. I
was trying to group this query like this, (Property1 OR Property2) NOT
{{PAGENAME}} which would be a double query, pick all matches, then eliminate
this one.

Tom


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: #ask query syntax

badon
Well, I'm glad you were able to figure it out! Sometimes you just need a second brain on the problem to help sort out possibilities until you find the avenue that leads to the result you're trying to achieve.
Loading...