[Freebase-discuss] Query for topics which do not have a certain type

Tom Morris tfmorris at gmail.com
Fri Dec 31 19:02:11 UTC 2010


I too am curious what Simon is trying to do.  I've added a TinyURL for
the first of Maria's three queries.  Comments are below.

On Thu, Dec 30, 2010 at 9:59 AM, Maria Mollo
<maria.mollo at imagespacemedia.com> wrote:
> So this doesn't work out to require results be typed as /common/topic and
> also as either /opera/opera music/composition?
>
> [{
>   "type": [{
>     "id": "/common/topic"
>   }],
>   "and:type|=": [
>     "/opera/opera",
>     "/music/composition"
>   ],
>   "id":     null,
>   "name":   null,
>
> }]

Let's call this one http://tinyurl.com/36h5z3r

> I tried fiddling with it in the query editor, first by getting the count for
> /common/topic being forbidden, while asking for either opera or composition.
> (34 results)   -- http://tinyurl.com/2fk54cl
> Then took a guess that the above would work (return count: 60149) because it
> looked right to me. -- http://tinyurl.com/36h5z3r
> Then pretended I was in 2nd grade math class and "checked my work before I
> handed it in," by ignoring the impact of common/topic entirely and just
> asking for anything typed either as /opera/opera or /music/composition.
> (return count: 60183)  --  http://tinyurl.com/29ajpth
> I thought that if the numbers worked out, then the above would address the
> issue. But I'm still learning as I go, so if I'm missing some fundamental
> concept that invalidates my attempt, please let me know.

So the three queries are:

1. /common/topic AND (opera OR composition) -- 60138 results --
http://tinyurl.com/36h5z3r
2. opera OR composition -- 60172 results -- http://tinyurl.com/29ajpth
3.  (NOT /common/topic) AND (opera OR composition) -- 34 results --
http://tinyurl.com/2fk54cl

60138 + 34 = 60172 (My numbers are different than Maria's because the
database has changed in the mean time)

What Simon asked for, I think, is the union of query #2 plus the
following "untyped" query:
(see http://wiki.freebase.com/wiki/MQL_Cookbook#Find_untyped_topics_.28or_which_only_have_a_given_type.29)

[{
   "id":          null,
   "name":        null,
   "t1:type":      "/common/topic",
   "t2:type": {
     "id":       null,
     "key": {
       "namespace": "/common",
       "optional":  "forbidden",
       "value":     "topic"
     },
     "optional": "forbidden",
   }
 }]

892,070 results -- http://tinyurl.com/2w3s2jp (that query will timeout
if you try to count them all, but that's how many untyped topics there
were as of Monday)

I don't think it's possible to get the union of these two queries in a
single query (as Kirrily said).  If Simon explains what he's trying to
do though, perhaps someone will come up with a clever solution that
doesn't require the impossible.

Tom

>> On Tue, Dec 21, 2010 at 4:08 PM, Simon <hs767151 at gmail.com> wrote:
>> >
>> > What I really, really want is anything that just has
>> >
>> >  \common\topic
>> >
>> > or also has other types only if they include
>> >
>> > /opera/opera
>> > or
>> > /music//composition
>> >
>> >
>> > Possible in 1 query?
>> >
>> > (Why do I feel I'm going round in circles?)
>> >
>> > Simon


More information about the Freebase-discuss mailing list