[Developers] how to get items with properties having null values?

Christopher R. Maden crism at metaweb.com
Mon Feb 9 23:10:48 UTC 2009


Raymond Yee wrote:
> I'd like to pull up all chemical elements whose boiling points are null 
> (i.e., that have no value).  Using parallax, you can see a table of 
> elements along with the boiling points:
> 
> I figured out how to get elements whose boiling points are not null by 
> asking for "boiling_point<" : 100000 -- since all real elements have bp 
> < 1000000 C but any null elements would return false:
> 
> The question I have is how to ask for non-null values more directly.  
> How do I say something like
> 
> "boiling_point!=" : null

What you are missing is the syntax to require or forbid values for 
properties.

To find all elements *with* boiling points:

[
   {
     "atomic_number" : null,
     "boiling_point" : {
       "value" : null
     },
     "name" : null,
     "sort" : "atomic_number",
     "type" : "/chemistry/chemical_element"
   }
]

By putting the value in an object, you are requiring a value to be 
present; a simple null matches no value at all.

You can find all elements *without* boiling points like this:

[
   {
     "atomic_number" : null,
     "boiling_point" : {
       "optional" : "forbidden",
       "value" : null
     },
     "name" : null,
     "sort" : "atomic_number",
     "type" : "/chemistry/chemical_element"
   }
]

The "value" clause matches only values that are present; the 
"optional":"forbidden" directive then eliminates them.

~Chris
-- 
Christopher R. Maden
Data Architect
Freebase.com: <URL: http://www.freebase.com/ >
Metaweb Technologies, Inc. <URL: http://www.metaweb.com/ >


More information about the Developers mailing list