Query Constructor¶
The AFLUX requests are compiled by a Query
class that is accessed via the search()
function. It
supports chaining of methods to construct the relevant query. Each of
the methods is described below, though we recommend looking at
Example Queries with aflow.
Functions for controlling high-level search functionality for the AFLOW database.
-
class
aflow.control.
Query
(catalog=None, batch_size=100, step=1)[source]¶ Represents a search againts the AFLUX API.
Parameters: -
filters
¶ list – of str filter arguments to pass to the matchbook section of the API request.
-
select
[source]¶ list – of
aflow.keywords.Keyword
to include in the request.
-
excludes
¶ list – of
aflow.keywords.Keyword
to exclude in the request.
-
orderby
[source]¶ str – name of the keyword to order by. AFLUX only supports a single order-by parameter for now.
-
catalog
¶ str – one of the catalogs supported on AFLOW: [‘icsd’, ‘lib1’, ‘lib2’, ‘lib3’]. Also supports a list of catalog names.
-
N
¶ int – number of results in the current search query.
-
reverse
¶ bool – when True, reverse the order of the results in the query.
-
k
¶ int – number of datasets per page for the current iterator. Can be controlled by batch_size.
-
responses
¶ dict – keys are (n,k) tuples from the pagination; values are the corresponding JSON dictionaries.
-
step
¶ int – step size over entries.
-
exclude
(*keywords)[source]¶ Sets a keyword to be excluded from the response.
Parameters: keywords (list) – of aflow.keywords.Keyword
that encapsulates the AFLUX request language logic.
-
filter
(keyword)[source]¶ Adds a search term to the current filter list. Calling
filter()
multiple times will join the final filters together using logical and.Parameters: keyword (aflow.keywords.Keyword) – that encapsulates the AFLUX request language logic.
-
finalize
()[source]¶ Finalizes the current state of the query. This means that the request URL will be saved, but the individual keyword objects will be reset. Re-executing the search query will reconstruct the same object and request, but any cached responses will be lost.
-
max_N
¶ Returns the maximum integer index that will be reached by this query.
-
n
¶ Current page number for the iterator.
-
orderby
(keyword, reverse=False)[source] Sets a keyword to be the one by which
Parameters: - keyword (aflow.keywords.Keyword) – that encapsulates the AFLUX request language logic.
- reverse (bool) – when True, reverse the ordering.
-
reset_iter
()[source]¶ Resets the iterator back to zero so that the collection can be iterated over again without needing to request the data from the server again.
-
select
(*keywords)[source] Adds a keyword to the list of properties to return for each material in the request.
Parameters: keywords (list) – of aflow.keywords.Keyword
that encapsulates the AFLUX request language logic.
-
-
aflow.control.
search
(catalog=None, batch_size=100)[source]¶ Returns a
aflow.control.Query
to help construct the search query.Parameters:
-
aflow.control.
server
= 'http://aflowlib.duke.edu/search/API/?'¶ str – API server address over HTTP.