Re: [SMW-devel] Help with ask queries - using intermediate results

2012-11-09 Thread Yury Katkov
Well you can also use template format if you don't like subqueries... It
would also help you to use the intermediate results.

-
Yury Katkov, WikiVote




On Wed, Nov 7, 2012 at 5:44 PM, Marcelo Chiaradía 
chiaradiamarc...@gmail.com wrote:

 Hi everyone,

 I'm trying to make an #ask query, using intermediates results to do more
 queries within.

 I have this scenario:

 I have several pages of a category A. Some of them are related to other
 pages of category B, through a has B property. Then, my B pages are
 related to pages of category C, through has C property, and finally my C
 pages have an attribute att1, through has att1 property, wich has
 defined a specific set of values.

 I would like to make an ask query, asking for all my A pages, whose must
 have at least one B page, which must have at least one C page, and which
 must have the att1 = SOME_VALUE, where some value should be a parameter.

 I read about subqueries, doing something like:

 {{#ask: [[Category::A]] [[has B::q[[Category::B]] [[has C::

 q[[Category::C]] [[has att1::{{SOME_VALUE}}]]/q]]
  /q]]
 |?att1
 }}

 Is this the right way to do this? is there a more elegant way?

 One other thing, I would like that if the user doesn't complete the
 SOME_VALUE parameter, then return all the pages of category A. I tried
 this with the + and * characters, but didnt work. How is the best way
 to achieve this?

 Thanks a lot in advance,

 Marcelo.


 --
 LogMeIn Central: Instant, anywhere, Remote PC access and management.
 Stay in control, update software, and manage PCs from one command center
 Diagnose problems and improve visibility into emerging IT issues
 Automate, monitor and manage. Do more in less time with Central
 http://p.sf.net/sfu/logmein12331_d2d
 ___
 Semediawiki-devel mailing list
 Semediawiki-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Help with ask queries - using intermediate results

2012-11-09 Thread Markus Krötzsch
On 07/11/12 13:44, Marcelo Chiaradía wrote:
 Hi everyone,

 I'm trying to make an #ask query, using intermediates results to do more
 queries within.

 I have this scenario:

 I have several pages of a category A. Some of them are related to other
 pages of category B, through a has B property. Then, my B pages are
 related to pages of category C, through has C property, and finally my
 C pages have an attribute att1, through has att1 property, wich has
 defined a specific set of values.

 I would like to make an ask query, asking for all my A pages, whose
 must have at least one B page, which must have at least one C page, and
 which must have the att1 = SOME_VALUE, where some value should be a
 parameter.

 I read about subqueries, doing something like:

 {{#ask: [[Category::A]] [[has B::q[[Category::B]] [[has C::
   
   q[[Category::C]] [[has att1::{{SOME_VALUE}}]]/q]]
   /q]]
 |?att1
 }}

 Is this the right way to do this? is there a more elegant way?

This is the right way. We are open to proposals for nicer looking 
syntax, but the general approach is correct.


 One other thing, I would like that if the user doesn't complete the
 SOME_VALUE parameter, then return all the pages of category A. I tried
 this with the + and * characters, but didnt work. How is the best
 way to achieve this?

You need to omit the [[has att1::...]] altogether if you do not want any 
restriction on this property. You can use an #ifeq to do this whenever 
{{SOME_VALUE}} is empty.

Cheers,

Markus



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Help with ask queries - using intermediate results

2012-11-09 Thread Markus Krötzsch
On 09/11/12 09:37, Yury Katkov wrote:
 Well you can also use template format if you don't like subqueries... It
 would also help you to use the intermediate results.

That would let you see the intermediate results (otherwise, there is 
no way to find out which of, say, the has C values was responsible 
for having a line in the result). If you really need this, and the 
information cannot be retrieved later (e.g. if you know that there is 
only one has C on any page anyway), then templates might help.

However, using templates with queries to format other queries is 
generally a bad approach that is extremely inefficient and will use a 
lot of memory and CPU to display a page (results are fetched from the 
database, rendered as wikitext, re-parsed as queries, which are used to 
fetch more results, ...); it will only work at all of your inner results 
are very limited in number.

Markus




 On Wed, Nov 7, 2012 at 5:44 PM, Marcelo Chiaradía
 chiaradiamarc...@gmail.com mailto:chiaradiamarc...@gmail.com wrote:

 Hi everyone,

 I'm trying to make an #ask query, using intermediates results to do
 more queries within.

 I have this scenario:

 I have several pages of a category A. Some of them are related to
 other pages of category B, through a has B property. Then, my B
 pages are related to pages of category C, through has C property,
 and finally my C pages have an attribute att1, through has att1
 property, wich has defined a specific set of values.

 I would like to make an ask query, asking for all my A pages,
 whose must have at least one B page, which must have at least one C
 page, and which must have the att1 = SOME_VALUE, where some value
 should be a parameter.

 I read about subqueries, doing something like:

 {{#ask: [[Category::A]] [[has B::q[[Category::B]] [[has C::
   
   q[[Category::C]] [[has att1::{{SOME_VALUE}}]]/q]]
   /q]]
 |?att1
 }}

 Is this the right way to do this? is there a more elegant way?

 One other thing, I would like that if the user doesn't complete the
 SOME_VALUE parameter, then return all the pages of category A. I
 tried this with the + and * characters, but didnt work. How is
 the best way to achieve this?

 Thanks a lot in advance,

 Marcelo.

 
 --
 LogMeIn Central: Instant, anywhere, Remote PC access and management.
 Stay in control, update software, and manage PCs from one command center
 Diagnose problems and improve visibility into emerging IT issues
 Automate, monitor and manage. Do more in less time with Central
 http://p.sf.net/sfu/logmein12331_d2d
 ___
 Semediawiki-devel mailing list
 Semediawiki-devel@lists.sourceforge.net
 mailto:Semediawiki-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/semediawiki-devel




 --
 Everyone hates slow websites. So do we.
 Make your web apps faster with AppDynamics
 Download AppDynamics Lite for free today:
 http://p.sf.net/sfu/appdyn_d2d_nov



 ___
 Semediawiki-devel mailing list
 Semediawiki-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/semediawiki-devel



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Help with ask queries - using intermediate results

2012-11-09 Thread Marcelo Chiaradía
Thanks a lot for your answer. By the way, is there any extension needed to
run sub-queries?

Marcelo.

2012/11/9 Markus Krötzsch mar...@semantic-mediawiki.org

 On 09/11/12 09:37, Yury Katkov wrote:

 Well you can also use template format if you don't like subqueries... It
 would also help you to use the intermediate results.


 That would let you see the intermediate results (otherwise, there is no
 way to find out which of, say, the has C values was responsible for
 having a line in the result). If you really need this, and the information
 cannot be retrieved later (e.g. if you know that there is only one has C
 on any page anyway), then templates might help.

 However, using templates with queries to format other queries is generally
 a bad approach that is extremely inefficient and will use a lot of memory
 and CPU to display a page (results are fetched from the database, rendered
 as wikitext, re-parsed as queries, which are used to fetch more results,
 ...); it will only work at all of your inner results are very limited in
 number.

 Markus




 On Wed, Nov 7, 2012 at 5:44 PM, Marcelo Chiaradía
 chiaradiamarc...@gmail.com 
 mailto:chiaradiamarcelo@**gmail.comchiaradiamarc...@gmail.com
 wrote:

 Hi everyone,

 I'm trying to make an #ask query, using intermediates results to do
 more queries within.

 I have this scenario:

 I have several pages of a category A. Some of them are related to
 other pages of category B, through a has B property. Then, my B
 pages are related to pages of category C, through has C property,
 and finally my C pages have an attribute att1, through has att1
 property, wich has defined a specific set of values.

 I would like to make an ask query, asking for all my A pages,
 whose must have at least one B page, which must have at least one C
 page, and which must have the att1 = SOME_VALUE, where some value
 should be a parameter.

 I read about subqueries, doing something like:

 {{#ask: [[Category::A]] [[has B::q[[Category::B]] [[has C::

   q[[Category::C]] [[has att1::{{SOME_VALUE}}]]/q]]
   /q]]
 |?att1
 }}

 Is this the right way to do this? is there a more elegant way?

 One other thing, I would like that if the user doesn't complete the
 SOME_VALUE parameter, then return all the pages of category A. I
 tried this with the + and * characters, but didnt work. How is
 the best way to achieve this?

 Thanks a lot in advance,

 Marcelo.

 --**--**
 --
 LogMeIn Central: Instant, anywhere, Remote PC access and management.
 Stay in control, update software, and manage PCs from one command
 center
 Diagnose problems and improve visibility into emerging IT issues
 Automate, monitor and manage. Do more in less time with Central
 
 http://p.sf.net/sfu/**logmein12331_d2dhttp://p.sf.net/sfu/logmein12331_d2d
 __**_
 Semediawiki-devel mailing list
 
 Semediawiki-devel@lists.**sourceforge.netSemediawiki-devel@lists.sourceforge.net
 
 mailto:Semediawiki-devel@**lists.sourceforge.netSemediawiki-devel@lists.sourceforge.net
 
 
 https://lists.sourceforge.net/**lists/listinfo/semediawiki-**develhttps://lists.sourceforge.net/lists/listinfo/semediawiki-devel




 --**--**
 --
 Everyone hates slow websites. So do we.
 Make your web apps faster with AppDynamics
 Download AppDynamics Lite for free today:
 http://p.sf.net/sfu/appdyn_**d2d_nov http://p.sf.net/sfu/appdyn_d2d_nov




 __**_
 Semediawiki-devel mailing list
 Semediawiki-devel@lists.**sourceforge.netSemediawiki-devel@lists.sourceforge.net
 https://lists.sourceforge.net/**lists/listinfo/semediawiki-**develhttps://lists.sourceforge.net/lists/listinfo/semediawiki-devel



--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov___
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel


Re: [SMW-devel] Help with ask queries - using intermediate results

2012-11-09 Thread Markus Krötzsch
On 09/11/12 13:34, Marcelo Chiaradía wrote:
 Thanks a lot for your answer. By the way, is there any extension needed
 to run sub-queries?

No, subqueries are a standard part of SMW's query language and all 
storage backends support them. There are also some forms of subqueries 
for which you don't need qs:

[[property1.property2::Value]]

is short for

[[property1::q[[property2::Value]]/q]]

But this won't work if you have more conditions to check in the subquery 
(e.g.., categories in your case).

Markus


 2012/11/9 Markus Krötzsch mar...@semantic-mediawiki.org
 mailto:mar...@semantic-mediawiki.org

 On 09/11/12 09:37, Yury Katkov wrote:

 Well you can also use template format if you don't like
 subqueries... It
 would also help you to use the intermediate results.


 That would let you see the intermediate results (otherwise, there
 is no way to find out which of, say, the has C values was
 responsible for having a line in the result). If you really need
 this, and the information cannot be retrieved later (e.g. if you
 know that there is only one has C on any page anyway), then
 templates might help.

 However, using templates with queries to format other queries is
 generally a bad approach that is extremely inefficient and will use
 a lot of memory and CPU to display a page (results are fetched from
 the database, rendered as wikitext, re-parsed as queries, which are
 used to fetch more results, ...); it will only work at all of your
 inner results are very limited in number.

 Markus




 On Wed, Nov 7, 2012 at 5:44 PM, Marcelo Chiaradía
 chiaradiamarc...@gmail.com mailto:chiaradiamarc...@gmail.com
 mailto:chiaradiamarcelo@__gmail.com
 mailto:chiaradiamarc...@gmail.com wrote:

  Hi everyone,

  I'm trying to make an #ask query, using intermediates
 results to do
  more queries within.

  I have this scenario:

  I have several pages of a category A. Some of them are
 related to
  other pages of category B, through a has B property.
 Then, my B
  pages are related to pages of category C, through has C
 property,
  and finally my C pages have an attribute att1, through
 has att1
  property, wich has defined a specific set of values.

  I would like to make an ask query, asking for all my A pages,
  whose must have at least one B page, which must have at
 least one C
  page, and which must have the att1 = SOME_VALUE, where
 some value
  should be a parameter.

  I read about subqueries, doing something like:

  {{#ask: [[Category::A]] [[has B::q[[Category::B]] [[has C::

  q[[Category::C]] [[has
 att1::{{SOME_VALUE}}]]/q]]
/q]]
  |?att1
  }}

  Is this the right way to do this? is there a more elegant way?

  One other thing, I would like that if the user doesn't
 complete the
  SOME_VALUE parameter, then return all the pages of
 category A. I
  tried this with the + and * characters, but didnt work.
 How is
  the best way to achieve this?

  Thanks a lot in advance,

  Marcelo.


 
 --__--__--
  LogMeIn Central: Instant, anywhere, Remote PC access and
 management.
  Stay in control, update software, and manage PCs from one
 command center
  Diagnose problems and improve visibility into emerging IT
 issues
  Automate, monitor and manage. Do more in less time with Central
 http://p.sf.net/sfu/__logmein12331_d2d
 http://p.sf.net/sfu/logmein12331_d2d
  _
  Semediawiki-devel mailing list
 Semediawiki-devel@lists.__sourceforge.net
 mailto:Semediawiki-devel@lists.sourceforge.net
  mailto:Semediawiki-devel@__lists.sourceforge.net
 mailto:Semediawiki-devel@lists.sourceforge.net
 https://lists.sourceforge.net/__lists/listinfo/semediawiki-__devel
 https://lists.sourceforge.net/lists/listinfo/semediawiki-devel




 
 --__--__--
 Everyone hates slow websites. So do we.
 Make your web apps faster with AppDynamics
 Download AppDynamics Lite for free today:
 http://p.sf.net/sfu/appdyn___d2d_nov
 http://p.sf.net/sfu/appdyn_d2d_nov




 _
 Semediawiki-devel mailing list