In [1]:
from mdf_forge.forge import Forge
In [2]:
mdf = Forge()
In [3]:
mdf.match_field("material.elements", "Al")
Out[3]:
You can use match_field() as many times as you like to add more fields and values. (This applies to all of the query builder helpers.)
In [4]:
mdf.match_field("mdf.source_name", "oqmd*")
Out[4]:
Once you're done adding fields, use the search() method to execute your search. You don't need to specify the advanced argument; when using the query builder functions it is always set to True.
After you execute a search, the query is cleared from memory.
In [5]:
res = mdf.search(limit=10)
res[0]
Out[5]:
In [6]:
mdf.exclude_field("material.elements", "Cu")
Out[6]:
You can chain calls together if you want.
In [7]:
mdf.exclude_field("mdf.source_name", "sluschi").match_field("material.elements", "Al").exclude_field("mdf.source_name", "oqmd")
Out[7]:
In [8]:
res = mdf.search(limit=10)
res[0]
Out[8]:
In [ ]: