from mdf_forge.forge import Forge

mdf = Forge()

"""
Explanation: Part 2 - Core Query Builder Functions
End of explanation
"""


mdf.match_field("material.elements", "Al")

"""
Explanation: Query builders
match_field
Forge has many helper functions to make constructing queries easier. The simplest of the helpers is match_field().
To use match_field(), provide it with the field and value to match on.
End of explanation
"""


mdf.match_field("mdf.source_name", "oqmd*")

"""
Explanation: 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.)
End of explanation
"""


res = mdf.search(limit=10)
res[0]

"""
Explanation: 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.
End of explanation
"""


mdf.exclude_field("material.elements", "Cu")

"""
Explanation: exclude_field
exclude_field() is the opposite of match_field(); it excludes results with the specified value.
End of explanation
"""


mdf.exclude_field("mdf.source_name", "sluschi").match_field("material.elements", "Al").exclude_field("mdf.source_name", "oqmd")

res = mdf.search(limit=10)
res[0]

"""
Explanation: You can chain calls together if you want.
End of explanation
"""


